|
|
|
|
|
by int_19h
3213 days ago
|
|
> That's why I just stored UTF-8 in a normal string and avoided the whole mess. This only works if every library that you use agrees with you on this, and treats all strings you pass to it as UTF-8 whenever encoding matters. OTOH, if you don't care about that, then you might as well just use bytes everywhere, and get the same thing. At least in Python 3, with bytes, if a library does try to use it as a string, you'll get an error, rather than silent wrong output. |
|
Not exactly. The library just has to treat it as a string and not worry about the encoding (i.e. not try to encode it to/from the unicode type).
Only ran into this issue once and the library had an option to return everything as string so not a problem.
> At least in Python 3, with bytes, if a library does try to use it as a string, you'll get an error, rather than silent wrong output.
Bytes in Python 3 don't support string operators.