소스 검색

enforce utf8 encoding with replacement of unprintable characters during amalgamation

Julius Pfrommer 7 년 전
부모
커밋
8c7e7ea237
1개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 3
      tools/amalgamate.py

+ 3 - 3
tools/amalgamate.py

@@ -3,9 +3,9 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import print_function
-import re
 import argparse
 import os.path
+import re
 import io
 
 parser = argparse.ArgumentParser()
@@ -26,7 +26,7 @@ guard_re = re.compile("^#(?:(?:ifndef|define) [A-Z_]+_H_|endif /\* [A-Z_]+_H_ \*
 
 print ("Starting amalgamating file "+ args.outfile)
 
-file = io.open(args.outfile, 'w')
+file = io.open(args.outfile, 'w', encoding='utf8', errors='replace')
 file.write(u"""/* THIS IS A SINGLE-FILE DISTRIBUTION CONCATENATED FROM THE OPEN62541 SOURCES
  * visit http://open62541.org/ for information about this software
  * Git-Revision: %s
@@ -60,7 +60,7 @@ extern "C" {
 #endif\n''' % (outname.upper() + u"_H_", outname.upper() + u"_H_") )
 
 for fname in args.inputs:
-    with io.open(fname, encoding="utf8") as infile:
+    with io.open(fname, encoding='utf8', errors='replace') as infile:
         file.write(u"\n/*********************************** amalgamated original file \"" + fname + u"\" ***********************************/\n\n")
         print ("Integrating file '" + fname + "'...", end=""),
         for line in infile: