Author Topic: How to generate an Unicode string under MASM 6.15?  (Read 11983 times)

W0LF

  • Regular Member
  • *
  • Posts: 6
Re: How to generate an Unicode string under MASM 6.15?
« Reply #15 on: May 05, 2017, 06:38:50 AM »
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:
Code: [Select]
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:
Code: [Select]
; 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

  • Regular Member
  • *
  • Posts: 6
Re: How to generate an Unicode string under MASM 6.15?
« Reply #16 on: May 05, 2017, 06:41:42 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

  • Member
  • *****
  • Posts: 10543
  • Assembler is fun ;-)
    • MasmBasic
Re: How to generate an Unicode string under MASM 6.15?
« Reply #17 on: May 05, 2017, 07:51:07 AM »
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

  • Regular Member
  • *
  • Posts: 38
Re: FUC
« Reply #18 on: May 05, 2017, 10:13:15 AM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 7538
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: How to generate an Unicode string under MASM 6.15?
« Reply #19 on: May 05, 2017, 06:50:40 PM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

TWell

  • Member
  • ****
  • Posts: 748
Re: How to generate an Unicode string under MASM 6.15?
« Reply #20 on: May 05, 2017, 07:40:25 PM »
@W0LF,
This version works
Code: [Select]
; 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

  • Regular Member
  • *
  • Posts: 6
Re: How to generate an Unicode string under MASM 6.15?
« Reply #21 on: May 05, 2017, 07:59:01 PM »
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

  • Regular Member
  • *
  • Posts: 6
Re: How to generate an Unicode string under MASM 6.15?
« Reply #22 on: May 05, 2017, 08:32:40 PM »
It works, but...

http://savepic.net/9286853.htm

 :greensml:

Code: [Select]
; 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

  • Member
  • *****
  • Posts: 10543
  • Assembler is fun ;-)
    • MasmBasic
Re: How to generate an Unicode string under MASM 6.15?
« Reply #23 on: May 05, 2017, 08:44:09 PM »
It works, but...
Does the exe in Reply #17 work?

Quote
include      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

  • Member
  • ****
  • Posts: 748
Re: How to generate an Unicode string under MASM 6.15?
« Reply #24 on: May 05, 2017, 09:12:41 PM »
I thought both text should be russian language.
Code: [Select]
;Заголовок
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 ;)
« Last Edit: May 07, 2017, 08:08:53 PM by TWell »

nidud

  • Member
  • *****
  • Posts: 1980
    • https://github.com/nidud/asmc
Re: How to generate an Unicode string under MASM 6.15?
« Reply #25 on: May 05, 2017, 10:06:18 PM »
That is, in order to use the unicode in the program, should I use the unicode-editor?

No. Source code is always ASCII.

Quote
I use Notepad++ with ansi codepage.

Assuming your a Russian wolf you write the "text" in ASCII.

Code: [Select]
include windows.inc
include commctrl.inc
include tchar.inc

.code

_tmain proc _CDecl

MessageBox( NULL, "Teªáâ", "‡a£o«o¢oª", MB_OK )
ret

_tmain endp

end _tstart

Using Unicode directly in an ASCII source file is obviously a problem so you need to define them as resource or external binaries.

Code: [Select]
include windows.inc
include commctrl.inc
include tchar.inc

.data

string1 label byte
incbin <string1.txt>,2
dw 0

.code

_tmain proc _CDecl

MessageBox( NULL, "Hello World", addr string1, MB_OK )
ret

_tmain endp

end _tstart

The last test case works on my machine but the first one depends on your OS. I will however assume it show the correct text (at least some of the characters :lol:) in a Russian version of Windows.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7538
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: How to generate an Unicode string under MASM 6.15?
« Reply #26 on: May 05, 2017, 10:11:14 PM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

W0LF

  • Regular Member
  • *
  • Posts: 6
Re: How to generate an Unicode string under MASM 6.15?
« Reply #27 on: May 05, 2017, 10:15:09 PM »
Does the exe in Reply #17 work?

Yes, it work.

Quote
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

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

Quote
P.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--

  • Administrator
  • Member
  • ******
  • Posts: 7538
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: How to generate an Unicode string under MASM 6.15?
« Reply #28 on: May 08, 2017, 06:04:51 AM »
I move the discussion to the Workshop.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: