I'm loading a Korean CP51949 (EUC-KR) encoded ANSI file into an array of strings (LoadStringsFromFile). My system and the intended end user systems do not have CP51949 set as a legacy non-Unicode encoding.
At the moment I have 2 problems with this:
- Unless I run the application with Locale Emulator (which is just annoying, since the setup itself is in English only), the Korean text is displayed as gibberish.
Posgives wrong results andStringChangefails completely unless I switch toString, do the thing, and then back toAnsiString.
So, I'm wondering if there's a way to convert the array to unicode, and then back before saving.
To convert a file encoded in a specific Ansi encoding to Unicode
string(UTF-16 LE), useMultiByteToWideCharfunction:(Note that I'm using
TStringsto store strings/lines collection instead ofTArrayOfString, asTStringsis easier to work with)To convert Unicode
stringback to Ansi, useWideCharToMultiBytefunction:Use the functions like:
Works correctly on my English-only system: