![]() and what do you do if your target locale is among the not supported on your client's machine? Then there is the point that the standard library, for what it is capable of doing, is depending on which locales are supported on the machine your software is running on. ![]() This includes all the std:: variants in existence at this time. So, any case conversion that works on a character at a time, or worse, a byte at a time, is broken by design. Another example would be std::tolower( 'I' ), which should yield different results depending on the locale - virtually everywhere you would expect i, but in Turkey ı (LATIN SMALL LETTER DOTLESS I) is the correct answer (which, again, is more than one byte in UTF-8 encoding). And 2), the standard only ever operates on one character at a time, so it cannot decide whether Σ is in the middle of a word (where σ would be correct), or at the end ( ς). Because 1), the standard only ever operates on one character at a time, so it simply cannot turn ß into SS as would be correct. substr() could result in invalid (sub-) strings because you split in the middle of a multibyte sequence.Īs soon as you try something like std::toupper( 'ß' ), or std::tolower( 'Σ' ) in any encoding, you are in trouble. You are storing a multibyte character sequence in a container that is not aware of the multibyte concept, and neither are most of the operations you can perform on it! Even something as simple as. ![]() If you are using UTF-8 ( the only sane choice among the 8-bit encodings) with std::string as container, you are already deceiving yourself if you believe you are still in control of things. If you don't, your conversion routine will break silently on cases you are probably not even aware of existing.įirst you have to answer a question: What is the encoding of your std::string? Is it ISO-8859-1? Or perhaps ISO-8859-8? Or Windows Codepage 1252? Does whatever you're using to convert upper-to-lowercase know that? (Or does it fail miserably for characters over 0x7f?) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |