chr - what's this?
Jon Ribbens
jon+usenet at unequivocal.eu
Sat Jan 5 09:44:57 EST 2019
On 2019-01-05, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
> ram at zedat.fu-berlin.de (Stefan Ram) writes:
>> print( chr( 0x231E )) # Unicode Character 'BOTTOM LEFT CORNER' (U+231E)
>> File "~~~\Python\Python37\lib\encodings\cp1252.py", line 19, in encode
>
> I also have:
>
> print(chr)
><built-in function chr>
>
> . Don't see how the call gets to cp1252.py. I see:
>
> bltinmodule.c.h
>
> #define BUILTIN_CHR_METHODDEF \
> {"chr", (PyCFunction)builtin_chr, METH_O, builtin_chr__doc__},
It isn't chr() that's throwing the exception, it's print().
chr(0x231e) is returning a unicode string, print() is trying
to display that string on stdout, and apparently on your
machine Python thinks stdout is encoded as cp1252.
More information about the Python-list
mailing list