4 ms·
UTF-8 strings can be compared with strcmp(), you just can't get alphabetical sorting out of it. Most other str*() functions also work with UTF-8 encoded strings
by flohofwoe 6y ago
UTF-8 strings can be compared with strcmp(), you just can't get alphabetical sorting out of it. Most other str*() functions also work with UTF-8 encoded strings, you just need to know what to expect (e.g. splitting with strtok() works as long as the delimiters are all 7-bit ASCII chars, etc...).
- deathanatos 6y ago> UTF-8 strings can be compared with strcmp() No, they can't? These two UTF-8 byte sequences in a C char pointer, c3 a9 00 65 cc 81 00 Represent the same string, but do not compare equal with strcmp. And it's not just that; you've noted how strtok will break down. strchr() can't be used w/ a non-ASCII needle, there is no support for code units, etc.
- account42 6y ago> you just can't get alphabetical sorting out of it Lexicographical sorting over UTF-8 strings is actually the same as lexicographical sorting over the corresponding Unicode code point sequence.