News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

How define unicode string in Uasm?

Started by morgot, March 10, 2025, 12:05:33 AM

Previous topic - Next topic

morgot

Hello.

In nasm I can:
WndFont dw __utf16__'Tahoma',0
I fasm I can:
WndFont du 'Tahoma',0
What can I do in uasm? Except for perversions like db 'T',0,'A'...
Sorry for the bad English

zedd151

Not that I use uasm or Unicode at all, but maybe this will help? This post from jj2007...

https://masm32.com/board/index.php?msg=124589
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

zedd151

Upon further investigations into using UNICODE... but with masm32 SDK and ml.exe    :biggrin:
For masm32, this is valid and produces UNICODE strings via "UCC" macro (which is a synonmym for the UCCSTR macro - @hutch lol), and uses the "W" version of the api called via  "__UNICOE__ equ 1", specified before all of the includes+libs.

Format = UCC  varname, "the string", 0 where UCC indicates unicode text, it seems.

__UNICODE__ equ 1  ; use "W" version of api's

include \masm32\include\masm32rt.inc

.data

    UCC  msg_str,"Hello World!", 0 ; produces a unicode string
    UCC  ttl_str, "The Title", 0  ; produces a unicode string
   
.code
 
start:

  invoke MessageBox, 0, addr msg_str, addr ttl_str, MB_OK
  exit

end start
Its not a perfect system, but appears to work (for ml.exe and masm32 SDK)
Not what you asked for I know, but I wanted to try this for myself. Sorry for the tangent.

Unicode Message box example using Masm32 SDK attached
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

morgot

Quote from: zedd151 on March 10, 2025, 01:49:24 AMNot that I use uasm or Unicode at all, but maybe this will help? This post from jj2007...

https://masm32.com/board/index.php?msg=124589
I have error A2008:syntax error : LITERALS

 zedd151,your code works, but how to use ansi string?) If I want use them  too.
Sorry for the bad English

zedd151

Quote from: morgot on March 10, 2025, 03:48:57 AM
Quote from: zedd151 on March 10, 2025, 01:49:24 AMNot that I use uasm or Unicode at all, but maybe this will help? This post from jj2007...

https://masm32.com/board/index.php?msg=124589
I have error A2008:syntax error : LITERALS

 zedd151,your code works, but how to use ansi string?) If I want use them  too.

Not really my code but borrowed bits and pieces from hutchs unicode examples, and played with it 'til it worked as expected.
Not sure if unicode and ANSI ascii can be used together in a __UNICODE__ defined program.

I was just playing around to see what works in Masm32 for unicode.  :smiley:
Maybe someone else with more experience using both unicode and ascii in the same program can help you better.

If you are referring to jj2007's code that I posted a link to, you'd have to ask him.
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

six_L

Hi, morgot
Ascii => Unicode
.data
    W_WndFont    db 32 dup (0)
    WndFont     db 'Tahoma',0
.code
    invoke    MultiByteToWideChar,CP_ACP,0,addr WndFont,-1,addr W_WndFont,32   
    invoke    MessageW,0,addr W_WndFont,0,MB_OK
Say you, Say me, Say the codes together for ever.

Vortex

Hi morgot,

You can use Hutch's WSTR macro to define UNICODE strings. Here is a quick example :

.386
.model flat,stdcall
option casemap:none

include UniCodeMacros.inc

MessageBoxW PROTO :DWORD,:DWORD,:DWORD,:DWORD
MessageBox TEXTEQU <MessageBoxW>

ExitProcess PROTO :DWORD

.data


WSTR    msg,"This is a UNICODE sample."
WSTR    capt,"Hello"

.code

start:

    invoke  MessageBox,0,\
            ADDR msg,ADDR capt,0

    invoke  ExitProcess,0

END start

johnsa

In UASM you can declare a unicode string with DW.

aString dw "Hello, World!", 0