News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

How to use utf-16 strings ?

Started by morgot, July 02, 2021, 08:14:44 AM

Previous topic - Next topic

morgot

Hello,
In 32 bit masm was good macro uni$, but in 64 bit this not exists.

I see 2 variants:
1. str1 dw 's','t','r','o','k','a',0,0
2. use TimoVJ program to convert via str dw 73h,74h,72h,6Fh,6Bh,61h,0

but maybe someone wrote simpler macros?
Sorry for the bad English

HSE

Hi morgot,

In code section perhaps work: uni$ MACRO RegAux, arglist:VARARG
      LOCAL DATA@NAME
      WSTR DATA@NAME,arglist
      lea &RegAux, DATA@NAME
      EXITM <&RegAux>
    ENDM


Use?:uni$(rax, stroka)
Equations in Assembly: SmplMath

morgot

Don't works.

uni$(rax,"rundll.dll")
invoke LoadLibraryW,uni$(rax,"rundll.dll")


and my masm64 don't know WSTR - in macros64\macros64.inc
Sorry for the bad English

Vortex

Hi morgot,

You can import the required macros to your source code. Attached is a quick example.

morgot

Thank Vortex, it's very good!
but uni$ macro don't work, only WSTR
Sorry for the bad English

Vortex

Hi morgot,

Some slight modifications in the original macros ( practical solution ) :

uni$ MACRO arglist:VARARG
      LOCAL UCdata
      WSTR UCdata,arglist
      EXITM <ADDR UCdata>
    ENDM

uni2$ MACRO arglist:VARARG
      LOCAL UCdata
      WSTR UCdata,arglist
      EXITM <OFFSET UCdata>
    ENDM


include \masm32\include64\masm64rt.inc
include UnicodeMacros.asm

.data

WSTR format,"%s"

.code

start PROC

    invoke  vc_wprintf,uni$("%s"),uni$("This is a UNICODE test.",13,10)

    mov     rdx,uni2$("This is the second UNICODE test.",13,10)

    invoke  vc_wprintf,ADDR format,rdx

    invoke  ExitProcess,0

start ENDP

END


A better version of uni$ is required here to handle both of the usage cases above.