Author Topic: unicode string macros bug!  (Read 675 times)

morgot

  • Regular Member
  • *
  • Posts: 46
unicode string macros bug!
« 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.
Sorry for the bad English

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6754
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: unicode string macros bug!
« Reply #1 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

morgot

  • Regular Member
  • *
  • Posts: 46
Re: unicode string macros bug!
« Reply #2 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
Sorry for the bad English

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6754
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: unicode string macros bug!
« Reply #3 on: May 16, 2019, 07:04:55 AM »
You can try using "!!".
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

morgot

  • Regular Member
  • *
  • Posts: 46
Re: unicode string macros bug!
« Reply #4 on: May 16, 2019, 07:47:30 AM »
It works only when I type '!!!!' (four) characters. '!!','!!!' dont work.

Sorry for the bad English

jj2007

  • Member
  • *****
  • Posts: 9792
  • Assembler is fun ;-)
    • MasmBasic
Re: unicode string macros bug!
« Reply #5 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.

morgot

  • Regular Member
  • *
  • Posts: 46
Re: unicode string macros bug!
« Reply #6 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 '!' ?
Sorry for the bad English

Mikl__

  • Member
  • ****
  • Posts: 770
Re: unicode string macros bug!
« Reply #7 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>

jj2007

  • Member
  • *****
  • Posts: 9792
  • Assembler is fun ;-)
    • MasmBasic
Re: unicode string macros bug!
« Reply #8 on: May 26, 2019, 05:28:50 PM »
include \masm32\MasmBasic\MasmBasic.inc         ; download
  Init
  uMsgBox 0, cfm$("Добро пожаловать\nمرحبا بكم\n歡迎"), "Unicode is so damn complicated!!", MB_OK
EndOfCode