News:

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

Main Menu

How to generate an Unicode string under MASM 6.15?

Started by Iznogoode, May 03, 2017, 12:20:26 AM

Previous topic - Next topic

Iznogoode

Hi,
I have some difficulty imagining how to declare a Unicode string in MASM 6.15 with a simple directive (like DUS in GoAsm, for example). I know the classic system consisting in a loop lods/stosw (with ah=0) but I won't like  having to generate code. I read a post from ragdog where he discussed about WSTR but I did not understand, even by consulting the Microsoft programming manual. Can someone give me a solution ?
Thank you in advance !

Ps: I'm afraid my English is disastrous... :greenclp:

jj2007

Hi Iznogoode,

There are many solutions, see e.g. Unicode and displaying non-Latin alphabets.

The lodsb+stosw trick works only for pseudo unicode, as you certainly know. This is under the hood of the Masm32 macros uc$(), uni$(), and the MasmBasic macro wChr$().

Even this works: Print "Введите текст здесь", CrLf$

What is your specific objective here? Short code, simple code, fast code, ...?

newrobert

i remember masm can call windows api mutlitto... function convert asiic to unicode string;

Iznogoode

Thank you for your responses !
@jj2007: I am a beginner in assembler under Windows after using a lot MASM under DOS in the early 90s. Being studying the structures DLGTEMPLATE and DLGITEMTEMPLATE, I discovered that the strings had to be specified in Unicode format. So I wondered about the possibility of directly declare these strings in Unicode. GoAsm (and probably NASM too) can, but not MASM 6.15 which is, if I'm not wrong, the only version to run autonomously (beyond that, Visual C ++ is required). So I do not have a specific project. Unfortunately, I don't have a PC for the moment and I will study your precious suggestions in a little more than 2 weeks.

@newrobert: thank you very much for your info. I know, indeed, the function MultiByteToWide that allows to perform this conversion but I'm rather interested in a direct declaration of the string in Unicode'

nidud

#4
deleted

TWell


hutch--

There are a number of ways to do unicode in MASM which does not directly support unicode. You can put unicode strings in a resource file and load them that way. MASM32 has a tool for converting unicode text to DW sequences that you put in the initialised data section. The last way is to use the API that converts ASCII to UNICODE

newrobert

some editor also support unicode, such as notepad++ and ultra-edit, you can select menu from encode menu,
then you can select assic,utf-8 or usc2;

hutch--

The MASM32 SDK already provides a unicode editor for exactly the purpose of editing unicode RC scripts so that characters sets from around the world can be used in Windows applications created with MASM.

jj2007

Quote from: newrobert on May 04, 2017, 12:16:06 PM
some editor also support unicode

One editor also supports Formatted UniCode:

include \masm32\MasmBasic\MasmBasic.inc
  Init
  Inkey "Formatted UniCode: Введите текст здесь"
EndOfCode

> assic,utf-8 or usc2

Btw, I've heard of utf-8, but what are the others? assic, usc2?

TWell

What formats as source file ml.exe 6.15 accept?

jj2007

The snippet above builds and runs fine with ML 6.15 (and all other assemblers except ML 6.14). RichMasm exports it as UTF-8.

Even ML 10.0, AsmC and HJWasm cannot digest Unicode.

Attached three sources for testing:
- utf8
- unicode with BOM
- unicode without BOM

You can open them with RichMasm or Notepad. Qeditor opens them but the display will look a bit garbled.

W0LF

Hi all! May I ask in this tread about unicode? Thx :)
In a lot of masm's .inc-files I see macros: ifdef __UNICODE__ then bla-bla_1 else bla-bla_2.
So HOW I can define that "__UNICODE__" variable?

nidud

#13
deleted

hutch--

WOLF,

Have a read of the help files as they explain how to use the __UNICODE__ equate. When you define the equate you get the UNICODE API functions instead of the ANSI ones.