The MASM Forum

General => The Workshop => Topic started by: TouEnMasm on April 13, 2013, 05:21:02 PM

Title: MACRO for chains in ANSI and/or UNICODE format
Post by: TouEnMasm on April 13, 2013, 05:21:02 PM
I have searched a set of macros who are accepted by ml and JWASM.
It had been a challenge to reach the goal.
Samples are included in the asm file.
Here the result.
Title: Re: MACRO for chains in ANSI and/or UNICODE format
Post by: Vortex on April 13, 2013, 06:01:12 PM
Hi ToutEnMasm,

Kindly, could you provide some example usages?
Title: Re: MACRO for chains in ANSI and/or UNICODE format
Post by: Gunther on April 13, 2013, 07:46:35 PM
Hi ToutEnMasm,

yes, some examples would be a great help. Thank you.

Gunther
Title: Re: MACRO for chains in ANSI and/or UNICODE format
Post by: TouEnMasm on April 13, 2013, 10:04:47 PM

The download is an asm files with samples of use (messagebox).
Compile it with jwasm or ml and you will see the result.
The only who can be missing is the sdk32.inc ,get it below


comment * «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    The SDK32 Runtime Library include file.

  ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««« *

      .686p   
.XMM
.MMX
                                 
      .model flat, stdcall                     
      option casemap :none               

.NOLIST
include translate.inc ;SDK translate include files
include windows.sdk

;     libraries
;     ~~~~~~~~~
    ; ------------------------------------------
    ; import libraries for Windows API functions
    ; ------------------------------------------
      includelib gdi32.lib
      includelib user32.lib
      includelib kernel32.lib
      includelib Comctl32.lib
      includelib comdlg32.lib
      includelib shell32.lib
      includelib oleaut32.lib
      includelib ole32.lib

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

To switch from ansi to unicode just comment or uncomment those two lines.
Quote
   UNICODE equ
   __UNICODE__ equ UNICODE


Title: Re: MACRO for chains in ANSI and/or UNICODE format
Post by: Gunther on April 14, 2013, 01:41:30 AM
Hi ToutEnMasm,

Quote from: ToutEnMasm on April 13, 2013, 10:04:47 PM
To switch from ansi to unicode just comment or uncomment those two lines.
Quote
   UNICODE equ
   __UNICODE__ equ UNICODE

thank you.  :t

Gunther
Title: Re: MACRO for chains in ANSI and/or UNICODE format
Post by: dedndave on April 14, 2013, 12:20:31 PM
i'm going to have to take a French class   :P
Title: Re: MACRO for chains in ANSI and/or UNICODE format
Post by: TouEnMasm on April 14, 2013, 04:08:39 PM

Here is the translate  ;)

The CANS write an ANSI chain in data
The CUNI  write an UNICODE chain in data
The CANS_UNI write an ANSI or UNICODE chain in data ( depends of UNICODE switch)
---------- Used in function -------------------------------
PAU   return the addr of an Ansi or Unicode string write in data
PAA   return the addr of an Ansi string write in data
PUU  return the addr of an Unicode string write in data

replace the P with a O in those macros and get the Offset instead of the adress




Title: Re: MACRO for chains in ANSI and/or UNICODE format
Post by: dedndave on April 14, 2013, 10:45:38 PM
i was trying to read the comments - lol
i can use google translate, i guess
Title: Re: MACRO for chains in ANSI and/or UNICODE format
Post by: jj2007 on April 15, 2013, 06:34:46 AM
Just for curiosity: How do you handle "real" Unicode, e.g. Russian or Chinese? I.e. is there a macro similar to wRes$() (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1105)?

And given that your editor editmasm can handle Unicode, is there a way to write strings directly in Russian or Chinese?
Title: Re: MACRO for chains in ANSI and/or UNICODE format
Post by: TouEnMasm on April 15, 2013, 04:42:02 PM

My IDE editmasm use only ANSI to write code,the used of UNICODE is allowed in code by the SDK windows translated .
For the comparison with your macro,made it yourself ,you have the full source code.

Title: Re: MACRO for chains in ANSI and/or UNICODE format
Post by: jj2007 on April 15, 2013, 06:10:03 PM
What is the use of Unicode macros if you cannot display Russian or Chinese?
Title: Re: MACRO for chains in ANSI and/or UNICODE format
Post by: TouEnMasm on April 15, 2013, 08:32:37 PM
some functions need it,I just let microsoft made his soup.

Title: Re: MACRO for chains in ANSI and/or UNICODE format
Post by: TouEnMasm on April 26, 2013, 08:10:44 PM
Here another sample (from the masm32 package) who switch easily between ansi to unicode.
The executable is in unicode

later : the term  cumul in the two macro (CANS and CUNI) is too much usable  and must be replaced by a more unknown like @cumulwxyz.

IF CountTheNumberofChar EQ 0
[b]@cumulwxyz[/b] TEXTEQU <DB "&char">
[b]@cumulwxyz[/b] ;execute
ENDIF

Title: Re: MACRO for chains in ANSI and/or UNICODE format
Post by: TouEnMasm on August 11, 2021, 03:08:20 AM

Added a note about the term cumul who must be renamed @cumulwxyz to avoid conflict with other cumul (valuable for 32/64)