3 ms·
I don't understand how are surrogates in UTF16 a problem solved by UTF8. From the article it seems that two main improvements were smaller memory footprint due
by dmz73 4y ago
I don't understand how are surrogates in UTF16 a problem solved by UTF8.
From the article it seems that two main improvements were smaller memory footprint due to mostly ASCII data and using better algorithm which resulted in even better performance in UTF16.
I had to deal with surrogates in UTF16 and it is much easier than dealing with variable encoding in UTF8. Naive UTF8 decoder is easy and fast but if one takes time to fully validate each UTF8 code point then it becomes much more difficult and a lot slower...and that is going forward, trying to move backwards in UTF8 is again much harder than in UTF16.
The main disadvantage of UTF16 is memory usage when dealing with ASCII data but if that is the case then just use array of bytes and don't worry about unicode.