3 ms·
You missed my point entirely. Text in memory should be unicode and not encoded, as nothing else would really make sense. In that case bytes() refers to the size
by trezor 17y ago
You missed my point entirely. Text in memory should be unicode and not encoded, as nothing else would really make sense. In that case bytes() refers to the size of string when rendered in a specific encoding. You are not getting the "size" of the actual string.
See my other comment: http://news.ycombinator.com/item?id=628031 http://news.ycombinator.com/item?id=628031
- jrockway 17y agoBut you have to remember, even though there are millions of encodings and character sets, UTF-8 Unicode makes up 99.99% of real-world use-cases. So it makes sense to make that 99.99% easy. (I will admit that I'm confused as to why you would need to know the length of a string's representation in a certain encoding unless you are writing a network protocol.)