I am using the code on iOS to store dict in yaml file with Unicode support and transfer the file to s3 bucket:
with open(file_name, 'w') as outfile:
yaml.dump(backet, outfile, default_flow_style=False, allow_unicode=True)
s3.upload_file(file_name, BACKET, 'file.yaml')
then I am reading the file from the backet by:
response = s3.get_object(Bucket=BACKET, Key=ACCOUNTS)
configfile = yaml.safe_load(response["Body"])
and it works as expected on iOS platform.
when I am running the same code on windows, I got error back with unexpected symbol in the file. When I checked stored file, it has “wrong” symbols instead of unicode characters:
I tried to set encoding:
with open(file_name, 'w') as outfile:
yaml.dump(configfile, outfile, default_flow_style=False, allow_unicode=True, encoding='utf-8')
but it doesn’t help much. File will be stored with wrong encoding (it shows as windows-1251) when I download the file from the backet.
How to unify code to work on iOS and Windows OS?