flat assembler
Message board for the users of flat assembler.

Index > Main > fasm utf8

Author
Thread Post new topic Reply to topic
skykrnl



Joined: 17 Nov 2008
Posts: 21
skykrnl 23 Nov 2008, 11:58
code:

include 'encoding/utf8.inc'
_str du '我是中国人',0

build output:

fasm1.67.29 > fasm op.asm
flat assembler version 1.67.29 (1258685 kilobytes memory)
op.asm [4]:
_str du '我是中国人',0
D:\Assembler/fasm/inc/encoding/utf8.inc [79] du [1]:
du args }
D:\Assembler/fasm/inc/encoding/utf8.inc [46] du [41]:
load char byte from current+2
error: value out of range.

fasm utf8 bug?
Post 23 Nov 2008, 11:58
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20486
Location: In your JS exploiting you and your system
revolution 23 Nov 2008, 12:37
fasm does not support source files in UTF-8 or Unicode format. The macros for UTF-8 can only be used to create strings from the ASCII 8-bit input source file.

So that means your Chinese (I'm not sure if it is Chinese but anyway) characters (which are in UTF-8 or Unicode format) cannot be used in that way.

You need to use this:
Code:
_str dw 0x1234, 0xabcd, ...    
Post 23 Nov 2008, 12:37
View user's profile Send private message Visit poster's website Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6115
Location: Poland
MHajduk 23 Nov 2008, 12:51
revolution

Console version of FASM supports files encoded in UTF-8 format (did you see sources of my programs? Wink).

skykrnl

See, I've changed this example program from FASM 'Examples' subdirectory
Quote:

; example of simplified Win32 programming using complex macro features

include 'encoding\utf8.inc'
include 'win32wx.inc'

.data

_str du '我是中国人', 0

.code

start:
invoke MessageBox, HWND_DESKTOP, _str, '我是中国人', MB_OK
invoke ExitProcess, 0

.end start
and it is compiled with FASM 1.67.29 without problems. Smile See attachment.


BTW, 我是中国人 means "I am Chinese". Wink


Description:
Filesize: 2.65 KB
Viewed: 14527 Time(s)

Screenshot.png




Last edited by MHajduk on 23 Nov 2008, 13:02; edited 1 time in total
Post 23 Nov 2008, 12:51
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20486
Location: In your JS exploiting you and your system
revolution 23 Nov 2008, 12:55
MHajduk wrote:
Console version of FASM supports files encoded in UTF-8 format
Oh, thanks for the info, I was not aware Embarassed
MHajduk wrote:
(did you see sources of my programs? Wink).
No, I never took the time to look Embarassed
Post 23 Nov 2008, 12:55
View user's profile Send private message Visit poster's website Reply with quote
skykrnl



Joined: 17 Nov 2008
Posts: 21
skykrnl 23 Nov 2008, 13:17
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.

fasm 1.67.29 >fasm t.asm
flat assembler version 1.67.29 (1225152 kilobytes memory)
t.asm [8]:
_str du '我是中国人', 0
C:\Documents and Settings\User\桌面\fasmw16729/include/ENCODING/utf8.inc [79] du
[1]:
du args }
C:\Documents and Settings\User\桌面\fasmw16729/include/ENCODING/utf8.inc [46] du
[41]:
load char byte from current+2
error: value out of range.

21:15:58>


MHajduk wrote:
revolution

Console version of FASM supports files encoded in UTF-8 format (did you see sources of my programs? Wink).

skykrnl

See, I've changed this example program from FASM 'Examples' subdirectory
Quote:

; example of simplified Win32 programming using complex macro features

include 'encoding\utf8.inc'
include 'win32wx.inc'

.data

_str du '我是中国人', 0

.code

start:
invoke MessageBox, HWND_DESKTOP, _str, '我是中国人', MB_OK
invoke ExitProcess, 0

.end start
and it is compiled with FASM 1.67.29 without problems. Smile See attachment.


BTW, 我是中国人 means "I am Chinese". Wink
Post 23 Nov 2008, 13:17
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6115
Location: Poland
MHajduk 23 Nov 2008, 13:34
revolution wrote:
MHajduk wrote:
(did you see sources of my programs? Wink).
No, I never took the time to look Embarassed
Thank you for your honesty Wink.

skykrnl

I have Windows XP SP3 Home Edition. Are you sure that you don' make any error somewhere else in your source? See attachment:


Description:
Filesize: 56.8 KB
Viewed: 14507 Time(s)

Screenshot2.png


Post 23 Nov 2008, 13:34
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 23 Nov 2008, 13:54
skykrnl,

May be you can post offending source? I'd compiled MHajduk's example mod without a hitch and even run resulting .Exe — OK.
Post 23 Nov 2008, 13:54
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20486
Location: In your JS exploiting you and your system
revolution 23 Nov 2008, 14:01
[aol]Me too[/aol] although I get the result as shown below. But basically no problems here either.


Description:
Filesize: 3.39 KB
Viewed: 14496 Time(s)

UTF-8.JPG




Last edited by revolution on 23 Nov 2008, 14:03; edited 1 time in total
Post 23 Nov 2008, 14:01
View user's profile Send private message Visit poster's website Reply with quote
skykrnl



Joined: 17 Nov 2008
Posts: 21
skykrnl 23 Nov 2008, 14:02
please upload all the project files includes fasm,Thank you!

MHajduk wrote:
revolution wrote:
MHajduk wrote:
(did you see sources of my programs? Wink).
No, I never took the time to look Embarassed
Thank you for your honesty Wink.

skykrnl

I have Windows XP SP3 Home Edition. Are you sure that you don' make any error somewhere else in your source? See attachment:
Post 23 Nov 2008, 14:02
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20486
Location: In your JS exploiting you and your system
revolution 23 Nov 2008, 14:04
skykrnl wrote:
please upload all the project files includes fasm,Thank you!
The includes are in the standard fasm download. You should already have them.
Post 23 Nov 2008, 14:04
View user's profile Send private message Visit poster's website Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 13103
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 09 Jan 2009, 08:49
i might as well make it a screenshot.

the file is saved with UTF8 using notepad.


Description:
Filesize: 16.41 KB
Viewed: 14293 Time(s)

utf8.PNG




Last edited by sleepsleep on 09 Jan 2009, 08:56; edited 2 times in total
Post 09 Jan 2009, 08:49
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 09 Jan 2009, 11:45
Yep, known problem. FASM doesn't support files with Byte Order Mark.
Post 09 Jan 2009, 11:45
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Grom PE



Joined: 13 Mar 2008
Posts: 114
Location: i@grompe.org.ru
Grom PE 09 Jan 2009, 13:13
Heh, if you write "=5" on the first line, it doesn't complain anymore.
Post 09 Jan 2009, 13:13
View user's profile Send private message Visit poster's website Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 13103
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 10 Jan 2009, 01:53
awesome tips!!, it works gracefully, thanks Grom PE
Post 10 Jan 2009, 01:53
View user's profile Send private message Reply with quote
goldenspider



Joined: 16 May 2011
Posts: 38
goldenspider 05 Oct 2011, 09:42
aha, if you are Chinese, you can use utf16.inc.
for example:


Description:
Filesize: 40.74 KB
Viewed: 13281 Time(s)

t.jpg


Description:
Download
Filename: ENCODING.zip
Filesize: 46.58 KB
Downloaded: 566 Time(s)

Post 05 Oct 2011, 09:42
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.