News for hackers. Stuff that matters.
Re:It’s Not Wrong that “ ”.length == 7 by coldtea on Friday June 02, 2023 @03:12AM (#36162064)
>Should this throw an error because there's only one displayed "character"?

Absolutely.

Re:It’s Not Wrong that “ ”.length == 7 by BeefWellington on Friday June 02, 2023 @08:48AM (#36164367)
I think this is where the misunderstanding comes in. Python doesn't treat strings as char[] but as essentially unicode_codepoint[].

Whether this is a good idea on the whole is debatable, there's even a full PEP talking about the security concerns around doing it this way[1].

However, given this is how it works, the behaviour displayed makes complete sense to me and is the best of the bad choices presented by needing multi-byte strings.

[1]: https://peps.python.org/pep-0672/