4 ms·
The internal representation of Unicode objects is an implementation detail (configured at compile-time, it's generally UCS-2). So, for purposes of user code, n
by JulianWasTaken 14y ago
The internal representation of Unicode objects is an implementation detail (configured at compile-time, it's generally UCS-2).
So, for purposes of user code, no, you don't always have something in an encoding. You have some text (which is somehow stored in a way not exposed to you) or you have some encoded bytes.
- jiggy2011 14y agoSo, if I have this right decode() says "take this string which I believe is encoded in <encoding> and convert it into whatever the internal string representation is"?
- JulianWasTaken 14y agoYep. "And then allow me to treat it as text", semantically.
- dalke 14y agoIn the most recent version of Python, the implementation representation is a run-time detail, not compile-time. If you use ASCII then it's a one byte encoding. Most non-ASCII Unicode strings will have a two byte encoding, and if more than the Basic Multilingual Plane is needed, then Python will switch to a four byte encoding.