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

W0LF

Yes, thanks, after adding "__UNICODE__ equ 1" ML began to write unicode builds, but it also now gives errors despite the fact that I declare the strings through TCHAR:

D:\Archives\Dropbox\src>ml /c /coff 1.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rig

Assembling: 1.asm

*************
UNICODE Build
*************

1.asm(8) : error A2084: constant value too large
1.asm(9) : error A2084: constant value too large


This is my prog:

; Just an example!

__UNICODE__ equ 1

include D:\Programming\Masm32\include\masm32rt.inc

.data
sCaption TCHAR "Заголовок", 0, 0
sText TCHAR "Bla-bla-bla!", 0, 0

.code
start proc
invoke MessageBox, NULL, addr sText, addr sCaption, MB_OK
invoke ExitProcess, 0
start endp
end start

W0LF

Quote from: hutch-- on May 05, 2017, 05:42:59 AM
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.
Are you mean helps in "\Masm32\help\" ?

jj2007

More specifically, \Masm32\help\hlhelp.chm

If you don't find a solution in the Masm32 SDK, try this:

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  uMsgBox 0, "Заголовок", "Russian is cute:", MB_OK
EndOfCode

Source & exe attached; the MasmBasic library is needed to build it. All commands starting with w (like wide) are Unicode.

newrobert

Quote from: jj2007 on May 04, 2017, 04:57:03 PM
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?

sorry for misspell, should be ansi and usc2, ansi means 8-bit ascii code, and usc2 can reference following link:
https://en.wikipedia.org/wiki/Universal_Coded_Character_Set


hutch--

There is an editor in the MASM32 directory called "Uniedit" that write unicode text. It is supplied exactly for the purpose of writing UNICODE data to a unicode RC script.

TWell

@W0LF,
This version works; Just an example!

__UNICODE__ equ 1

include \Masm32\include\masm32rt.inc

.data
;sCaption TCHAR "Заголовок", 0, 0
;UCSTR sCaption, "Заголовок", 0 ; UTF-8 :(
sCaption dw 0417h,0430h,0433h,043Eh,043Bh,043Eh,0432h,043Eh,043Ah,0
;sText TCHAR "Bla-bla-bla!", 0, 0
UCSTR sText, "Bla-bla-bla!", 0 ; OK

.code
start proc
invoke MessageBox, NULL, addr sText, addr sCaption, MB_OK
invoke ExitProcess, 0
start endp
end start
PS: i used Notepad2 as editor, it support UTF-8 without BOM.

W0LF

That is, in order to use the unicode in the program, should I use the unicode-editor? I think not.
I use Notepad++ with ansi codepage.

W0LF

It works, but...

http://savepic.net/9286853.htm

:greensml:

; Just an example!

__UNICODE__ equ 1

include D:\Programming\Masm32\include\masm32rt.inc

.data
UCSTR sCaption, "Заголовок", 0, 0
UCSTR sText, "Текст на русском!", 0, 0

.code
start proc
invoke MessageBox, NULL, addr sText, addr sCaption, MB_OK
invoke ExitProcess, 0
start endp
end start


Thx all for help!  8)

jj2007

Quote from: W0LF on May 05, 2017, 08:32:40 PM
It works, but...
Does the exe in Reply #17 work?

Quoteinclude      D:\Programming\Masm32\include\masm32rt.inc

I am surprised that you can build something with a non-standard folder. The Masm32 SDK is built on the assumption that there is a folder \Masm32, which may look old-fashioned but has some advantages. Most of us use include \Masm32\include\masm32rt.inc

P.S.: Your code can work, but you need the RichMasm editor to do that (note it doesn't use MasmBasic):

; Just an example!

__UNICODE__      equ      1

include            \Masm32\include\masm32rt.inc            ; Open in RichMasm, hit F6

.data
UCSTR      sCaption, "Заголовок", 0, 0
; UCSTR      sText, "Текст на русском!", 0, 0
sText            db "Текст на русском!", 0, 0

.data?
buffer      db 1000 dup(?)

.code
start      proc
  invoke MultiByteToWideChar, CP_UTF8, 0, offset sText, -1, offset buffer, 100
  invoke      MessageBox, NULL, addr buffer, addr sCaption, MB_OK
  invoke      ExitProcess, 0
start      endp
end start

TWell

#24
I thought both text should be russian language.;Заголовок
sCaption dw 0417h,0430h,0433h,043Eh,043Bh,043Eh,0432h,043Eh,043Ah,0
;Текст на русском!
sText dw 0422h,0435h,043Ah,0441h,0442h,20h,043Dh,0430h,20h,0440h,0443h,0441h,0441h,043Ah,043Eh,043Ch,21h,0
EDIT: picture removed, as Steve don't like it ;)

nidud

#25
deleted

hutch--

Using unicode in win32 means an ASCII/ANSI text editor for code and a unicode editor to create and/or edit a unicode RC script.

W0LF

Quote from: jj2007 on May 05, 2017, 08:44:09 PM
Does the exe in Reply #17 work?

Yes, it work.

QuoteI am surprised that you can build something with a non-standard folder. The Masm32 SDK is built on the assumption that there is a folder \Masm32, which may look old-fashioned but has some advantages. Most of us use include \Masm32\include\masm32rt.inc

I was change all paths in masm32rt.inc. I don't want masm and sources in root folder, so they placed in subfolders.

QuoteP.S.: Your code can work, but you need the RichMasm editor to do that

My code works even without __UNICODE__ with russian symbols. I just wanted to see how it would look.
But I'm still grateful to all of you for your help and, I hope, you will help further.

hutch--