************************
ustring MACRO quoted_text
LOCAL asc_txt
.data
asc_txt db quoted_text,0
.code
invoke MultiByteToWideChar,CP_ACP,MB_PRECOMPOSED,ADDR asc_txt,-1,edi,LENGTHOF asc_txt
add edi, LENGTHOF asc_txt*2
ENDM
************************

in dialogs.inc,this macro seems to work incorrectly,if use Chinese string as caption.
coz this line

add edi, LENGTHOF asc_txt*2,

is not correct,if the asc_txt includes Chinese chars(or similar Asian string).the calculation should be as follow:

************************
invoke MultiByteToWideChar,CP_ACP,MB_PRECOMPOSED,ADDR asc_txt,-1,edi,LENGTHOF asc_txt
shl eax, 1
add edi, eax
************************

I'm a newbie,and not good at English,maybe i can't correctly expressed my meaning.

Regards.

JohnSd.
Posted on 2003-08-08 15:34:41 by JohnSd
hi, JohnSd

I'm newbe, to
and I agree with you. (As I learned at this board, hardcoding isn't a good techic)

MultiByteToWideChar
Return Values:
If the function succeeds, and cchWideChar is nonzero, the return value is the number of wide characters written to the buffer pointed to by lpWideCharStr.


may by this could be better:
lea edx,
Posted on 2003-08-08 19:12:08 by S.T.A.S.

hi, JohnSd

I'm newbe, to
and I agree with you. (As I learned at this board, hardcoding isn't a good techic)

MultiByteToWideChar
Return Values:
If the function succeeds, and cchWideChar is nonzero, the return value is the number of wide characters written to the buffer pointed to by lpWideCharStr.


may by this could be better:
lea edx,



none of the hardcoding's business,coz every Asian char has a size of 2 bytes,so in the ustring MACRO,

add edi, LENGTHOF asc_txt*2

will be wrong, i.e. All chars in one string are Asian char,the length of multibyte is the number of bytes,and after invoke MultiBYteToWideChar, the length of writing to the buffer is LENGTHOF asc_text/2, if add edi,LENGTHOF asc_txt*2,in fact,adds the wrong length.

Asian char diffrent from English char.if one string is a english char string, after MultiByteToWideChar, for example, string "abc" changed to "a\\0b\\0c\\0",
3 bytes to 6 byte, so add edi, LENGTHOF asc_text*2 is right.But Asian string's length will not be changed, still same length as the original string, in this case, add edi, LENGTHOF asc_text*2 is wrong.
Posted on 2003-08-08 20:38:22 by JohnSd
Hi, JohnSd

I just wanted to say that :
lea edx, -- 3 bytes

shl eax, 1 -- 2bytes
add edi, eax -- 2 bytes
total 4 bytes

so LEA is shorter (sometimes even than ADD), and quicker

hardcoding is : add edi, LENGTHOF asc_txt*2 - because of it you've got the problem
Posted on 2003-08-08 22:07:31 by S.T.A.S.
John,

Thanks for pointing this problem out, it has to do with me personally not having the experience in non ascii based character sets as I am a native English speaker without any other language.

What I would be inclined to do is very carefully rewrite the code that do the ANSI to UNICODE conversions so that you can use the character set you want and have it end up as UNICODE in the string as it is loaded into memory.

Take particular care with the alignment used as you can get serious crashes if its wrong or it just won't work and with no explanation or errors.

Regards,

http://www.asmcommunity.net/board/cryptmail.php?tauntspiders=in.your.face@nomail.for.you&id=2f46ed9f24413347f14439b64bdc03fd
Posted on 2003-08-09 00:59:16 by hutch--