flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > [SOLVED]fasm encode quoted string to multybyte utf8 string |
Author |
|
ProMiNick 03 Dec 2019, 07:16
all single cirillic chars will cause error except 3 ones:
Code: format binary as 'txt' include 'encoding/utf8.inc' du 'А' Code: format binary as 'txt' include 'encoding/utf8.inc' du 'Ё' Code: format binary as 'txt' include 'encoding/utf8.inc' du 'ё' Is it impossible in utf8 to encode single cirillic character? |
|||
03 Dec 2019, 07:16 |
|
Tomasz Grysztar 03 Dec 2019, 08:46
The "encoding/utf8.inc" macro is not to convert to UTF-8, it converts from UTF-8. So your source file should be using UTF-8 (and not Windows 1251 as it does), and what "du" produces is always UTF-16.
|
|||
03 Dec 2019, 08:46 |
|
ProMiNick 03 Dec 2019, 12:54
thanks, it helps.
Code: macro utf8 [arg] { local char,..data,size if arg eqtype '' virtual at 0 ..data:: db arg size = $ end virtual repeat size load char byte from ..data:%-1 if char < $80 db char else load char word from __encoding:char*2 if char > $7FF db $E0 + char shr (6*2),$80 + (char shr 6) and $3F,$80 + char and $3F else db $C0 + (char shr 6) and $3F,$80 + char and $3F end if end if end repeat else if arg eqtype 0 if arg > $7FF db $E0 + arg shr (6*2),$80 + (arg shr 6) and $3F,$80 + arg and $3F else if arg > $7F db $C0 + (arg shr 6) and $3F,$80 + arg and $3F else db arg end if else ;let standart directive handle error db arg end if } struc utf8 [args] { common label . word utf8 args } use macro(struc) utf8 only as encoding parasit over standart WIN... encodings for du directive. or at least needed to be defined apropriate table somewhere Code: virtual at 0 __encoding:: ... end virtual If anybody interested why was needed such conversation - there is small example (from my work - creating in fasm some receipt needed to show some developers that accessible set of operators is catastroficaly small, but yes this set still enought to solve problems - creating that receipt manualy possible too - but more mazahistic). https://yadi.sk/d/NLkxipN-NJcwpA |
|||
03 Dec 2019, 12:54 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.