Two persons had some trouble with Unicode: FileAppend Unicode text and Reading € from a file.
These were opportunities to develop some code around Microsoft's MultiByteToWideChar and WideCharToMultiByte functions.
As BoBo suggested, this code seems mature enough to put in this section.
The script I give here has no practical use as is. It is merely a demonstration of use of the functions, and is mostly designed as code snippets to copy and paste where needed.
It shows:
- Convert a text from plain Windows Ansi (ISO-8859-1/CP-1252) to Windows' Unicode (UCS-2/UTF-16) and back.
- Write and re-read a text encoded in Win Unicode, with or without Bom.
- Convert UTF-8 to Ansi (if relevant).
- Convert UTF-8 string to Win Unicode (UTF-16) and display it in a GUI (example with Japanese string).
The script must be downloaded: ReadWriteUnicodeText.ahk (it is 200 lines long, I don't like long code sections, and you can find fragments in the above topics).
Read and Write Unicode
Started by
PhiLho
, Jul 18 2006 04:28 PM
1 reply to this topic