Skip to content

Commit

Permalink
Merge pull request #1 from ixzhao/handle-non-ascii
Browse files Browse the repository at this point in the history
Handle non ascii
  • Loading branch information
digitalsleuth authored Oct 12, 2024
2 parents c95a33f + 102a5c5 commit 9a96f86
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pyson4.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def compress(file_block):
raise SystemExit(1)

try:
output_file = open(args.output_file, 'w')
output_file = open(args.output_file, 'w', encoding='utf-8')
except IOError as e:
print("Unable to write to '%s': %s" % (args.output_file, e), file=sys.stderr)
raise SystemExit(1)
Expand All @@ -72,7 +72,7 @@ def compress(file_block):
if args.d:
blob = decompress(input_file)
try:
json.dump(blob, output_file, indent=4, separators=(',',': '))
json.dump(blob, output_file, indent=4, ensure_ascii=False, separators=(',',': '))
output_file.write('\n')
except IOError as e:
print("Unable to write to '%s': %s" % (args.output_file, e), file=sys.stderr)
Expand All @@ -91,7 +91,7 @@ def compress(file_block):
output_file.write(blob)
except IOError as e:
print("Unable to write to '%s': %s" % (args.output_file, e), file=sys.stderr)
raise SystemExist(1)
raise SystemExit(1)
else:
output_file.close()
file_size = int(os.path.getsize(args.output_file))
Expand Down

0 comments on commit 9a96f86

Please sign in to comment.