mixpanel / mixpanel-utils

Other
87 stars 63 forks source link

specify encoding=utf-8 #32

Closed jaredmixpanel closed 3 years ago

jaredmixpanel commented 3 years ago

In Python 3, the default encoding when opening text files is system dependent, for MacOS or *nix this will be UTF-8, but for Windows it's the 8-bit Windows-1252, which was causing errors for some Windows users. Like...

...."C:\Users\peter\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\mixpanel_utils\__init__.py", line 1547, in _write_items_to_csv
    writer.writerow(row)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u014c' in position 34: character maps to <undefined>

This change will explicitly require the use of UTF-8 encoding for all text files.

https://mixpanel.slack.com/archives/CKGL4TYF3/p1627066714155600

https://stackoverflow.com/questions/44391671/python3-unicodeencodeerror-charmap-codec-cant-encode-characters-in-position/44400442#44400442