Author Topic: trouble in unicode  (Read 6346 times)

asmcoder

  • Guest
trouble in unicode
« on: December 26, 2013, 12:33:42 PM »
Hello everyone,
I have a trouble when using unicode.
My system is Chinese Simplified (Mainland China) , the program attached works fine.
But when I run the program in Chinese traditional (HongKong, TaiWan...) system , something unexpected happened.

i use the same unicode text to show in a msgbox and the dialog title.
the msgbox works fine.
but the  dialog title has some "?"

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: trouble in unicode
« Reply #1 on: December 26, 2013, 01:18:55 PM »
What happens if you create the dialog with the Unicode version of the DialogBoxParam function?
Well Microsoft, here’s another nice mess you’ve gotten us into.

dedndave

  • Member
  • *****
  • Posts: 8829
  • Still using Abacus 2.0
    • DednDave
Re: trouble in unicode
« Reply #2 on: December 26, 2013, 01:20:58 PM »
it's not a UNICODE window
i am surprised you got as far as you did

in the t2.asm file, comment out these lines
Code: [Select]
;.386
;.model flat, stdcall  ;32 bit memory model
;option casemap :none  ;case sensitive

include t2.inc

in the t2.inc file.....
Code: [Select]
__UNICODE__ EQU 1

include \masm32\include\masm32rt.inc
;include windows.inc
;include kernel32.inc
;include user32.inc
;include Comctl32.inc
;include shell32.inc

;includelib kernel32.lib
;includelib user32.lib
;includelib Comctl32.lib
;includelib shell32.lib

include String.inc

i can't tell if it works, because i don't have Traditional Chinese installed

asmcoder

  • Guest
Re: trouble in unicode
« Reply #3 on: December 26, 2013, 01:38:02 PM »
i debug it with olly, found that __UNICODE__ don't work, still generate DialogBoxParamA

when i manually type DialogBoxParamW, the unicode text works

asmcoder

  • Guest
Re: trouble in unicode
« Reply #4 on: December 26, 2013, 01:54:20 PM »
maybe my masm version is not 11 , i'll download it and try later.

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: trouble in unicode
« Reply #5 on: December 26, 2013, 02:43:25 PM »
There is also the IsWindowUnicode function.
Well Microsoft, here’s another nice mess you’ve gotten us into.

jj2007

  • Member
  • *****
  • Posts: 11529
  • Assembler is fun ;-)
    • MasmBasic
Re: trouble in unicode
« Reply #6 on: December 26, 2013, 07:13:28 PM »
t2Dlg.rc is missing in your archive above.

In case you have MasmBasic, attached a little test. I guess it's simplified Chinese.

asmcoder

  • Guest
Re: trouble in unicode
« Reply #7 on: December 26, 2013, 07:20:40 PM »
t2Dlg.rc is missing in your archive above.

In case you have MasmBasic, attached a little test. I guess it's simplified Chinese.

Thanks jj
t2Dlg.rc is in the Res folder.  i created the project using radasm2. 



After download masm11, use __UNICODE__  ,the problem solved.

white

  • Regular Member
  • *
  • Posts: 1
Re: trouble in unicode
« Reply #8 on: December 26, 2013, 10:30:40 PM »
how to define a unicode string has chinese words? sorry my english is poor

how to define a unicode string has chinese words? sorry my english is poor

I edited this because it was displaying in Chinese characters.
« Last Edit: December 26, 2013, 10:35:53 PM by hutch-- »

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 8440
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: trouble in unicode
« Reply #9 on: December 26, 2013, 11:05:09 PM »
White,

There are a couple of ways to display Chinese characters in MASM, normally source code for MASM must be written in ordinary ASCII characters but you can create an RC file in UNICODE where you can directly enter any UNICODE character including Chinese characters as resource strings. The other way is to make sequences in the .DATA section using the WORD data size (16 bit) and type the numbers for the UNICODE characters as an array of WORD size data elements.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 11529
  • Assembler is fun ;-)
    • MasmBasic
Re: trouble in unicode
« Reply #10 on: December 26, 2013, 11:20:44 PM »
With MasmBasic's RichMasm editor, you can even type your Unicode strings directly into the source, and display them using the wRes$() macro (when hitting F6, the editor exports the part between the two Rsrc marks to filename.rc, then builds the project):

asmcoder

  • Guest
Re: trouble in unicode
« Reply #11 on: December 26, 2013, 11:45:17 PM »
Hi, white.
you can download my attached files.
see string.inc

you can use $CTW0 ,  $TW0  , CCOUNTED_UNICODE_STRING  to define any unicode string, including Chinese

but you can not directly write Chinese in the source code, you need to write a translate program like this:



then
Code: [Select]
invoke MessageBoxW,0,$CTW0("\u4F60h\u597Dh\uFF0Ch\u6211h\u6765h\u81EAh\u4E2Dh\u56FDh\u0020h\u0068h\u0065h\u006Ch\u006Ch\u006Fh\u002Ch\u0069h\u0027h\u006Dh\u0020h\u0066h\u0072h\u006Fh\u006Dh\u0020h\u0043h\u0068h\u0069h\u006Eh\u0061h\u002Eh"),0,0
of course the english words need not to translate, also you can
Code: [Select]
invoke MessageBoxW,0,$CTW0("\u4F60h\u597Dh\uFF0Ch\u6211h\u6765h\u81EAh\u4E2Dh\u56FDh hello,i'm from China."),0,0
that means you can mix them