> See 7.2.3 (aliases) and 7.2.7 (utf_8_sig) in the codecs documentation.
>
> https://docs.python.org/3/library/codecs.html
>

The docs don't mention that case is immaterial for aliases, when it usually
matters in Python. The actual dictionary entries in aliases.py often differ
in case from the docs. For instance, this works:

>>> p = bytes("This sure sux", encoding="uTf32")
>>> p
b'\xff\xfe\x00\x00T\x00\x00\x00h\x00\x00\x00i\x00\x00\x00s\x00\x00\x00
\x00\x00\x00s\x00\x00\x00u\x00\x00\x00r\x00\x00\x00e\x00\x00\x00
\x00\x00\x00s\x00\x00\x00u\x00\x00\x00x\x00\x00\x00'
>>>

aliases.py
    # utf_8 codec
    'u8'                        : 'utf_8',
    'utf'                        : 'utf_8',
    'utf8'                      : 'utf_8',
    'utf8_ucs2'           : 'utf_8',
    'utf8_ucs4'           : 'utf_8',
    'ubom'                  : 'utf_8_sig'


So of course my favorite is u8 - less typing, and ubom for decoding if I
get those funny bytes ;')

-- 
Jim

If you only had one hour left to live, would you spend it on Facebook,
Twitter, or Google Plus?
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to