Skip to content

Commit 4eae890

Browse files
committed
tp: open files with utf-8 encoding in gen_amalgamted_sql.py (google#3343)
Fixes google#3342 ---- In Korean locales it is not unusual that the platform default encoding on Windows is the EUC-KR codepage, so on these and other systems that don't default to UTF-8, it would help to have any build script that loads UTF-8 files make that explicit in their code. Signed-off-by: Christian W. Damus <cdamus.ext@eclipsesource.com>
1 parent 434bc59 commit 4eae890

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/gen_amalgamated_sql.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def main():
8787

8888
sql_files = []
8989
if args.input_list_file:
90-
with open(args.input_list_file, 'r') as input_list_file:
90+
with open(args.input_list_file, 'r', encoding='utf-8') as input_list_file:
9191
for line in input_list_file.read().splitlines():
9292
sql_files.append(line)
9393
else:
@@ -102,7 +102,7 @@ def main():
102102
# Extract the SQL output from each file.
103103
sql_outputs = {}
104104
for file_name in sql_files:
105-
with open(file_name, 'r') as f:
105+
with open(file_name, 'r', encoding='utf-8') as f:
106106
relpath = os.path.relpath(file_name, root_dir)
107107

108108
# We've had bugs (e.g. b/264711057) when Soong's common path logic breaks
@@ -111,7 +111,7 @@ def main():
111111
assert '../' not in relpath
112112
sql_outputs[relpath] = f.read()
113113

114-
with open(args.cpp_out, 'w+') as output:
114+
with open(args.cpp_out, 'w+', encoding='utf-8') as output:
115115
output.write(REPLACEMENT_HEADER)
116116
output.write(NAMESPACE_BEGIN.format(args.namespace))
117117

0 commit comments

Comments
 (0)