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.
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/