flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > UTF-8 support with macro

Author
Thread Post new topic Reply to topic
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7419
Location: Kraków, Poland
Tomasz Grysztar
This macro, when defined at the beginning of program using the standard package of macros for Win32 programming, allows to use characters encoded with UTF-8 in the quoted strings (for example in resources), and they'll be properly converted to Unicode (note that fasmw is ASCII-based, so to enter such characters comfortably you need some editor with UTF-8 support, like Notepad in NT-based systems).
Code:
macro du [args]
 {
  common local ..count,..current,..byte,..wide
   virtual at 0
    db args
    ..count = $
   end virtual
   ..current = 0
   repeat ..count
    if ..current<..count
     virtual at 0
     db args
     load ..byte byte from ..current
     if ..byte<0C0h
      ..wide = ..byte
     else if ..byte<0E0h
      ..wide = (..byte and 11111b) shl 6
      ..current = ..current+1
      load ..byte byte from ..current
      ..wide = ..wide + (..byte and 111111b)
     else if ..byte<0F0h
      ..wide = (..byte and 1111b) shl 12
      ..current = ..current+1
      load ..byte byte from ..current
      ..wide = ..wide + (..byte and 111111b) shl 6
      ..current = ..current+1
      load ..byte byte from ..current
      ..wide = ..wide + (..byte and 111111b)
     else
      ..wide = ..byte ; higher currently unsupported
     end if
     ..current = ..current+1
     end virtual
     dw ..wide
    end if
   end repeat
 }
    
Post 22 Sep 2003, 18:27
View user's profile Send private message Visit poster's website Reply with quote
boysoledad



Joined: 14 Sep 2003
Posts: 10
boysoledad
hi but i can't write to encode to unicode in flat assembler. I'll see a error about hex in flat assembler.

Example:

i want display a string in title bar of win as with string "Tiếng Việt" then Error massege....
Post 26 Sep 2003, 09:03
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7419
Location: Kraków, Poland
Tomasz Grysztar
It's for UTF-8, not 16-bit Unicode - fasm needs ASCII source.
Also you should not save the whole source as UTF-8 with Notepad, as it's writing some header for such text files, and this header will cause an error.
Post 26 Sep 2003, 10:30
View user's profile Send private message Visit poster's website Reply with quote
boysoledad



Joined: 14 Sep 2003
Posts: 10
boysoledad
But with ur code, i have include where it's?
Post 27 Sep 2003, 02:25
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.