[python-win32] proper coding declaration
raf at raf.org
raf at raf.org
Mon Mar 4 23:45:35 EST 2019
bob gailer wrote:
> my python file starts with # -*- coding: utf-8 -*-
>
> There is a unicode character 2501 in the file
>
> I am editing with python for windows 3.7 build 224
>
> Saving the file results in an error: 'latin-1' codec can't encode character
> \u2501
>
> What am I doing wrong?
>
> --
> Bob Gailer
Just guessing but maybe the problem is that it's not a
UTF8 file and Python is falling back to latin1 (because
it knows it isn't ASCII).
You say there is a unicode character in it (\u2501).
But that character, encoded in UTF-8 is 0xE2 0x94 0x81.
Try changing the charset declaration to match the
actual unicode encoding that it is using. Not sure what
it is but possibly UTF-16.
cheers,
raf
More information about the python-win32
mailing list