4 ms·
The article should be called "What it takes to do anything Windows API in C++". For example, this Unicode issue is applicable to almost every API there. And it
by Lockal 3y ago
The article should be called "What it takes to do anything Windows API in C++". For example, this Unicode issue is applicable to almost every API there. And it is not as simple as "call MultiByteToWideChar twice". Microsoft did not support UTF-16, they UCS-2, which they called "Unicode", but in fact back then it was just a wider ASCII. The worst thing about UCS-2 is that it does not support roundtrip.
For example, imagine, that you wrote your Enterprise MS Tech Contoso Ltd.(R) authentication system, where user registers in UTF-8 on webpage, then on some layer it checks that user with the same name (in UTF-8 modern DB) does not exist, then it writes user basic information in UCS-2 encoded legacy "Enterprise DB". Aaand... Voila, Evil User overrides data of other user, because UTF-8 can't losslessly represent arbitrary sequences of 16-bit code units (should have used https://simonsapin.github.io/wtf-8/ https://simonsapin.github.io/wtf-8/ instead, but your Enterprise tech was destroyed).
- colejohnson66 3y agoThey called it “Unicode” because, at the time, thanks to Han Unification, UCS-2 was widely believed to be the one and only encoding that anyone would ever need. Two bytes per codepoint. No more, and no less. C#/.NET even inherit this misnomer and call UTF-16LE “Unicode”: System.Text.Encoding.UnicodeEncoding