Hi,

I am thinking of using unicode in my program. Do I just use the api that ends with W and if so how do I go about using them, since msdn has nothing on them. Also if I am not wrong, it does not work on all os, so what do I do if the unicode verison does not exist? Thanks anyway

Regards,
Victor
Posted on 2004-06-25 10:07:20 by roticv
It's easy using unicode if you have the right includes (I really should bugfix my protoize ;)), yes it's as simple as using the W APIs instead of the A ones. Defining unicode strings in masm can be a bit b1tchy, even with macros... I think GoAsm has better support for them.

Of course strings have to be double length, and remember that most API calls take *number of chars*, NOT *number of bytes*.

MSDN/PlatformSDK should state which functions are available where... also there's some conversion layer. Head over to the GoAsm site, I think Jeremy Gordon wrote a good deal about it.
Posted on 2004-06-25 10:15:05 by f0dder
Hi Roticv,

Here is the unicode all_api file from my GoAsm includes. It has all of the function equates for most of unicode ones in the standard API. Only those APIs that have a unicode wrapper are included in the file. Just as a BTW, GoAsm has full unicode support and has some very powerful features for unicode programs. It is in the form...

AbortSystemShutdown equ AbortSystemShutdownW

AccessCheckAndAuditAlarm equ AccessCheckAndAuditAlarmW
Posted on 2004-06-25 10:22:59 by donkey
what's the deal with unicode?
you want ppl in japan to use your app ? :D
Posted on 2004-06-25 16:34:49 by wizzra
MS distributes 'unicows' or something like that in order to provide wrappers or fake versions of Unicode APIs. Search MSDN. AFAIK, that DLL is redistributable, so you may bundle it with your app, and install it when you detect 16 bit OS + 32 bit GUI version of Windows.


what's the deal with unicode?
you want ppl in japan to use your app ? :D

Is this a joke? If it is not a joke, you must be specialized in very narrow area of programming.
Posted on 2004-06-25 19:29:39 by Starless
One advantage of using UNICODE on some versions of windows is to reduces overhead as the ASCII versions just convert the strings and call the wide character version of the function.
Posted on 2004-06-25 22:26:48 by bitRAKE

One advantage of using UNICODE on some versions of windows is to reduces overhead as the ASCII versions just convert the strings and call the wide character version of the function.


Also, some functions only have a Unicode version and no ASCII equivalent.
Posted on 2004-06-25 22:34:46 by Mecurius
Unicows is very simple to use, you have only to include the /MSLU switch when you link with GoLink or in MASM include the following *before* any other includelibs.

includelib unicows.lib


At that point you must have the following in your code (this is not necessary in GoAsm the stub is added by the linker)

.data

szUniLib BYTE "unicows.dll",0
szNoLib BYTE "This application uses Unicode functions",13,10,
"that require Microsoft Layer for Unicode",0
.code

LoadUnicows PROC
LOCAL osvi :OSVERSIONINFO

mov osvi.dwOSVersionInfoSize,SIZEOF OSVERSIONINFO
invoke GetVersionEx,ADDR osvi
.IF osvi.dwPlatformId != VER_PLATFORM_WIN32_NT
invoke LoadLibrary,OFFSET szUniLib
.IF eax == NULL
invoke MessageBox,NULL,OFFSET szNoLib,NULL,MB_OK
invoke ExitProcess,0
.ENDIF
.ENDIF

ret
LoadUnicows ENDP


Unicows and it's accompanying libs etc.. can be obtained from Microsoft...

MSLU

And by the way. If you use Unicows there are a few welcome surprises in Win9x, like the UpdateResource family of instructions actually work :alright:
Posted on 2004-06-25 23:04:16 by donkey
from MSDN

"Unicode is a specification for supporting character sets, like Japanese and Chinese, that cannot be represented in a single byte. If you are programming for an international market,"

i don't find it a joke :) that is what unicode created for.
Posted on 2004-06-26 15:20:39 by wizzra
Well,

as far as I know, TextOutW is preinstalled on every 32bit-Windows, so you won't have any compatibility problems.

Also preinstalled on every system is GetTextExtentPoint32W, which can help you to check the display size of the text.

Regards,
Claus
Posted on 2004-06-27 07:24:38 by ndn4u
Hi Donkey,

For support on 9x, all I need to do is to include unicows.dll and load the dll right? If it is so simple I will go straight to add support for unicode in faim asap.

Wizzra,
What I have in mind is chatting chinese, and not japanese, since I know chinese but not japanese ;)

Regards,
Victor
Posted on 2004-06-27 12:22:20 by roticv
For support on 9x, all I need to do is to include unicows.dll and load the dll right? If it is so simple I will go straight to add support for unicode in faim asap.


Yes, you must build with the unicows.lib file as the first lib in your project then load Unicows.dll at startup, this will set up an API hook to redirect and translate the API calls for 9x, do not load Unicows.dll on NT based systems. Note that it is very important to use the Unicows lib file and that it is the first lib included, this will override the other libs in the project for the affected API calls.
Posted on 2004-06-28 13:36:46 by donkey
Thanks Donkey,

But it seems like unicows.dll is way bigger than the application I am developing ;)
Posted on 2004-06-28 20:31:31 by roticv
Hi Roticv,

Yes, for small applications you are much better off just doing conversions in your program. Generally a check for NT and a separate execution path, but it means loading the APIs dynamically. You might think about putting some functions in a DLL and loading the proper DLL depending on the OS version, it would make it possible to do it without dynamic loading.
Posted on 2004-06-28 21:24:02 by donkey