The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: 4C617273H on September 19, 2010, 05:29:45 PM

Title: How to use Unicode "strings" properly ?
Post by: 4C617273H on September 19, 2010, 05:29:45 PM
Hello,

Windows has become more of a Unicode operating system than staying an "ANSI" os.

How do I work with Unicode throughout the application, ie. for "strings"?

Iczelion's tutorials use DB and ,0 for strings. Those are Define Byte and 0-terminated, correct?

Windows 7 uses UTF-16 though (reference: http://msdn.microsoft.com/en-us/library/dd317743(v=VS.85).aspx).

Now I use the EasyCode IDE with the Unicode application project property set. This should make EasyCode / MASM use the Unicode versions of an API ("W") if I don't specify a suffix myself, right?

However when using the TCITEM structure and its cchTextMax and pszText properties (and its imask) and using handcoded UTF-16 characters and the length of the string, the displayed string ends after the first character, probably because finding a 0 in the HiWord. String display reference: http://msdn.microsoft.com/en-us/library/bb760631(v=VS.85).aspx ,  TCITEM reference: http://msdn.microsoft.com/en-us/library/bb760554(v=VS.85).aspx

Am I missing something? If yes, what is it?

Thanks!

Lars
Title: Re: How to use Unicode "strings" properly ?
Post by: qWord on September 19, 2010, 05:40:08 PM
May it help to send the TCM_SETITEMW-Message explicit.
Title: Re: How to use Unicode "strings" properly ?
Post by: 4C617273H on September 19, 2010, 05:47:23 PM
Well, I use SendMessage. I would have to use SendMessageW if it exists. I didn't try this. Or would I have to change the message like you named it instead of changing the API ?

Thanks! Best
Title: Re: How to use Unicode "strings" properly ?
Post by: qWord on September 19, 2010, 05:50:55 PM
In case of SendMessage it doesn't matter if you are using the unicode or ANSI version - the message it self is the deciding factor.
Title: Re: How to use Unicode "strings" properly ?
Post by: Vortex on September 19, 2010, 05:56:39 PM
Also, have a loot at the UNICODE functions provided by masm32.lib :

Unicode String Functions

\masm32\help\masmlib.chm
Title: Re: How to use Unicode "strings" properly ?
Post by: ToutEnMasm on September 19, 2010, 06:04:07 PM

You need to have header files who accept the UNICODE syntax and then you can used the normal syntax ,the header made the modifies for you.
Just add UNICODE equ 1 to your code
If you don't want to use this,read the header and made manually the modifies.
The "ready to use sdk" allow this ( masm32 forum windows.inc project)
Title: Re: How to use Unicode "strings" properly ?
Post by: 4C617273H on September 19, 2010, 06:07:36 PM
Quote from: qWord on September 19, 2010, 05:50:55 PM
In case of SendMessage it doesn't matter if you are using the unicode or ANSI version - the message it self is the deciding factor.

Thanks!


Quote from: Vortex on September 19, 2010, 05:56:39 PM
Also, have a loot at the UNICODE functions provided by masm32.lib :

Unicode String Functions

\masm32\help\masmlib.chm

I did, didn't find anything helpful related though. A Unicode conversion function would be helpful (as an extra tool). Thank you too!


I will have a look whether sending the W message explicitly is resulting in the correct string displayed. Not tonight anymore though probably.

Quote from: ToutEnMasm on September 19, 2010, 06:04:07 PM

You need to have header files who accept the UNICODE syntax and then you can used the normal syntax ,the header made the modifies for you.
Just add UNICODE equ 1 to your code
If you don't want to use this,read the header and made manually the modifies.
The "ready to use sdk" allow this ( masm32 forum windows.inc project)


Thank you! I will check this!

Lars
Title: Re: How to use Unicode "strings" properly ?
Post by: 4C617273H on September 19, 2010, 07:07:47 PM
UNICODE equ 1

and

TCM_SETITEMW

were a success!

Thanks again!