The MASM Forum

Toddler's Corner => Romper Room => Topic started by: morgot on May 16, 2019, 04:55:38 AM

Title: unicode string macros bug!
Post by: morgot on May 16, 2019, 04:55:38 AM
Hello,

I write in my code:

Code: [Select]
invoke CreateFileW,uni$("\\MAIN\Download\!1.txt"), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0
But character '!' disappeared from the string. Why? Macros UNI$ deleted '!' ? Or there is local bug?

chr$ macro works good.
Title: Re: unicode string macros bug!
Post by: hutch-- on May 16, 2019, 05:50:39 AM
The "!" character is used specifically by MASM as a control character so it cannot be used in that context.
Title: Re: unicode string macros bug!
Post by: morgot on May 16, 2019, 06:51:19 AM
So, how I can use unicode string with this char?
Such as
Code: [Select]
xor ebx,ebx
invoke MessageBoxW,ebx,uni$("good!"),ebx,ebx
ansi char is not universal
Title: Re: unicode string macros bug!
Post by: hutch-- on May 16, 2019, 07:04:55 AM
You can try using "!!".
Title: Re: unicode string macros bug!
Post by: morgot on May 16, 2019, 07:47:30 AM
It works only when I type '!!!!' (four) characters. '!!','!!!' dont work.

Title: Re: unicode string macros bug!
Post by: jj2007 on May 16, 2019, 12:35:22 PM
It depends on the degree of expansion that the macro internally uses. Sometimes, two !! are sufficient, but often you need indeed four of them. Unfortunately, MASM uses some very common characters like !, &, % for internal purposes.
Title: Re: unicode string macros bug!
Post by: morgot on May 16, 2019, 09:30:27 PM
I try
Code: [Select]
un dw 'g','o','o','d','1','!',0,0it works.

but why macro chr$ works correctly with '!' ?
Title: Re: unicode string macros bug!
Post by: Mikl__ on May 26, 2019, 05:17:24 PM
Hi, morgot!
it is my macro for unicode with support for Cyrillic letters in Windows-1251
Code: [Select]
du macro string
local bslash
bslash = 0
irpc c,<string>
if bslash eq 0
if '&c' eq "/"
        bslash = 1
elseif '&c'gt 127
db ('&c'- 0B0h),4
else
dw '&c'
endif
else
           bslash = 0
           if '&c' eq "n"
           DW 0Dh,0Ah
           elseif '&c' eq "/"
           dw '/'
           elseif '&c' eq "r"
           dw 0Dh
           elseif '&c' eq "l"
           dw 0Ah
           elseif '&c' eq "s"
           dw 20h
           elseif '&c' eq "c"
           dw 3Bh
           elseif '&c' eq "t"
           dw 9
   endif
endif
endm
dw 0
endm
Example
Code: [Select]
du <Tutorial 10g: DialogBoxIndirectParam+DlgProc>
Title: Re: unicode string macros bug!
Post by: jj2007 on May 26, 2019, 05:28:50 PM
include \masm32\MasmBasic\MasmBasic.inc         ; download (http://masm32.com/board/index.php?topic=94.0)
  Init
  uMsgBox 0, cfm$("Добро пожаловать\nمرحبا بكم\n歡迎"), "Unicode is so damn complicated!!", MB_OK
EndOfCode