Your String is Not What You Think It Is





A Tour Through the Encoding Wars, and Why len("café") Returns 4


Reading time: ~13 minutes




You called len("café") and Python told you 4. You passed that string to a function that encoded it to bytes. The bytes were 5 long. You stared at the screen for longer than you'd admit.

Then you got a...