How to display a UNICODE string ???
Help me please ???
I use MASM32 9.0
I type a unicode string but it not dipslay truely...
please help me !
thanks
Hello!
Again, some more information would be usefull.
How would you like to display the string? In messageBoxes? Or in console output?
What do you mean by not display truely? Are there corrupted characters? Or the whole string is not appearing?
In windows, there are items that can display unicode text, though (as I could experience) unicode text must be converted via WideCharToMultiBye in most cases.
Please, describe your problem more precisely!
Greets, Gábor
dragonvn,
If you wish to display UNICODE you must select the UNICODE Windows API functions, not the ANSI ones that are more commonly used.
Thanks to you reply!
I want to display a unicode string ( Vietnamese) in a messagebox (i am from Vietnam).
can you help me ?
+ gabor !: I can type unicode directly in MASM32 and compile it ?
(for you: you must convert by WideCharToMultiBye...)
+hutch !: can you tell me more detail?
thanks
Masm can't support real unicode (unless your language's characters can be fit in 1 byte each). You'll have to put strings in the resource-file.
Then displaying that string is done via MessageBoxW() . The MessageBox() is actually renamed to MessageBoxA(). "A" stands for ASCII, "W" stands for WideChar. WideChar uses 2 bytes per character. All WindowsAPI functions, that have strings as parameters, have their "A" and "W" versions. The "A" versions simply convert the ASCII to WideChar, and then internally call the W version of the API function.
Here's the link of UNICODE types: http://en.wikipedia.org/wiki/Unicode
If I understood correctly function with W can only process UFT16 txt format, right? If that's true, what about UTF8 or 32?
UTF8 is not very useful. Even with languages of the Basic Multilingual Plane, string manipulations are too hard.
UTF32 takes too much memory.
Ok, are saying that Win functionsW are made ONLY for UTF-16? And if I have some UTF-8 encoded txt I have to encode it again to UTF-16?
Win32Hlp states that TextOut is Unicode ready in WinNT and Win95. But it really means UTF-16 ready!
Plane 0: 0000 - FFFF (16-bit): All languages
Plane 1: 10000 – 1FFFF : obsolete symbols (not used nowadays), musical symbols, mathematical symbols
Plane 2: used for 40000 rare/obsolete Chinese symbols
UTF16 is variable-width, so if the first WORD is special, it means that the next character is from the other planes (not plane 0).
Soooo.. WindowsNT's WideChar is really unicode, and you can safely bet that 1 WORD = 1 character (except for if your customers start using those 40000 rare/obsolete Chinese symbols...).
P.S.
You can convert UTF8 to UTF16 via
MultiByteToWideChar(CP_UTF8,0,pInputUTF8String,-1,pOutUTF16String,MaxSizeOfOutUTF16String);
and 16-to-8 via WideCharToMultiByte(....)
If UTF8 was used directly in WinAPI, it would probably slow-down parts of the OS. Because each handled character would have to be remapped, and procs like strlen16, strcpy16 and so on would always have to remap. I.e if you wanted to get the 10000th character, you'd have to decompress the 9999 characters before it.
hi Ultrano.
Could you tell me more detail code in MASM32 ?
for example: i want to display a message box with a unicode string(:Việt nam là đất nước tôi) on it.
???
help me ?
1) Put your string in the RSRC file.
2) Use LoadString
3) Use the W version of the function (currently MessageBoxW)
that's it
thank you! Ultrano !
dragonvn,
When you are finished, if it's not too much trouble, could you post the full source code please.