Attempt at Unicode.

BlitzMax Forums/BlitzMax Programming/Attempt at Unicode.

Robb(Posted 2006) [#1]
I've been using Blitzmax for a short while now and I'm quite disappointed to see that while it claims to support UTF-8 format, it cannot read or display text encoded in this way. I understand that for the majority this is not a problem, but I (like others I've seen on this board) need to display non-roman characters such as Japanese.

I know nothing of how UTF actually works, but so far I have managed to display Japanese text using an array of individual character codes (sourced using charmap) and reading them into a string.
Is there anyway of reading these codes into the array from a text file? I know readbyte() can be used for ASCII files but it doesn't work for UTF as its values exceed 255. Any suggestions?

I read a post from a year ago where Mark said that he was going to implement this function in the next version of BMax but unfortunately I don't think it happened :(
It’s a shame because living in Japan as I do, it would be a rather useful feature.

Here is my code for anyone who wants to see...

Strict
Graphics 800,600,0

Global font:Timagefont=LoadImageFont("c:\windows\fonts\msgothic.ttc",150,SMOOTHFONT)
SetImageFont font

Global kana[]=[12371,12435,12395,12385,12399]
Global s$


For Local i=0 To kana.length-1
	s$=s$+Chr(kana[i])
Next

While Not KeyHit(KEY_ESCAPE)
	Cls
	
	SetBlend alphablend
	SetScale 1,1
	DrawText s$,20,200
	SetScale 0.15,0.15
	DrawText "[konnichiwa]",350,350

	Flip
Wend

GCCollect



popcade(Posted 2006) [#2]
Actually the current BMax still can't handle it well, as in PureBasic you can simply use unicode text in strings etc.

As I said you can't even "comment" in with Japanese in the source, that cause the error, if it's getting fixed, should be worh waiting.

Actually it's boring to convert every unicode char to it's value, even with third party software, really hope get fixed.


Robb(Posted 2006) [#3]
Well because blitzmax's strings are supposedly 16bit unicode they should in theory work, but its a combination of the IDE and the file i/o that is preventing them *i think*.

I really hope it gets fixed too but its been an ongoing thing for ages now and for most people it doesn't seem to be very high priority requirement.


popcade(Posted 2006) [#4]
Same consideration here.

As side note I working on a Chinese project, glad to see there's users with same need, now we just have to wait for it.

If none get fixed I may back to VC2003... for easier string handling.


skidracer(Posted 2006) [#5]
The next update will feature unicode support in the IDE as well as new LoadText and SaveText commands that follow unicode .txt file conventions.


Jay Kyburz(Posted 2006) [#6]
That is very cool to hear skidracer!


Robb(Posted 2006) [#7]
That is great to hear!
I'll finally be able to get underway with my bilingual software :)


neilo(Posted 2006) [#8]
Hey Skidracer,

Very much looking forwards to this!!

Can you give us any idea as to how thorough unicode support will be? As in, will MaxGUI have full unicode support as well? Will (say) text boxes have full Input Method support?

Kind regards,

Neil


popcade(Posted 2006) [#9]
Currently I simply hope DrawText can work with this coming feature, then it can be used on writing something above Surface, which enables users easily blit unicode strings on current available 3D engines (3Impact, Irrlicht, Eliza3D...)

Really looking forward it's coming.