"Print" to console not UTF-8 friendly?

BlitzMax Forums/BlitzMax Beginners Area/"Print" to console not UTF-8 friendly?

Brucey(Posted 2006) [#1]
Is there something I'm missing or doesn't Print work when writing UTF-8 text to the console?
Here's a short example :
SuperStrict
Print "один"

EDIT :Yes... very funny.. that should be the Russian text for "one", but it's been converted by the forum-engine. You can try google translate for your own text...

On Windows, it prints :
один

which is, if I read correctly, the 4 UTF-8 characters separated out into it's 8-byte parts.

I expect I'll get the same results on Mac and Linux.
Perhaps it's a bug with the Stream of StandardIO ?

Ho hum..


Brucey(Posted 2006) [#2]
Okay... so now I seem know what I'm doing with UTF-8, I've got it working on Linux GTK (that is, Printing to the "Output" tab).
Seems that win32 must be buggy... :-)


pappavis(Posted 2006) [#3]
I've had a similair question sometime ago and was informed that Blitz can't output cyrrilic.
The advise from forum members was to output the russian text as consequetive (images/bitmaps) pictures. Its a solution, though not elegant.


ziggy(Posted 2006) [#4]
The problem is that some of the controls used by MaxGUI on windows are not very compatible with unicode chars (and the BlitzMax IDE is written in MaxGUI). You can redirect the print command un windows, or use another IDE.


Brucey(Posted 2006) [#5]
I've got it outputting cyrillic in Graphics mode (through DrawText, with a supporting font), but as you say, some of the Windows components don't seem very happy with it.

Also, I tried editing a file (in the IDE) on Windows which showed the proper text, but when I tried to load that file on Linux, gEdit said it wasn't UTF-8 (I thought Max saved as UTF-8 by default?).
Any hoo, I ended up having to load the file in the IDE on Linux, and save it from there, so that I could open it in gEdit.
But I can confirm that the Linux GTK IDE prints all non-ascii text as it should (assuming you have all the required fonts available).


Azathoth(Posted 2006) [#6]
Would it have anything to do with Windows using UCS-2?


Mark Tiffany(Posted 2006) [#7]
I briefly looked into this "bug" a while back. I'm pretty sure it is Win32 only, and was something to do with the stdio not supporting UTF8. I think skid knew a bit about this one, and you might be able dredge something up from one of his posts? It's certainly not the GUI controls, as the following spews rubbish when run from the command line, not just in the IDE.
For i = 0 To 255
Print Chr(i)
Next



ziggy(Posted 2006) [#8]
It's curious that if you use the Notify function, the UTF-8 is well supported... also, the UTF-8 output on the windows console is well output by C++ programs, but not by BlitzMax ones, so I supouse it is, in fact, not really a windows bug, but a BlitzMax one. I think a UTF-8 flag has to be initialized on windows, not sure how to do it.

here's an article:
http://www.microsoft.com/globaldev/getwr/steps/wrg_unicode.mspx#EWE

note that the only way to warranty unicode support on a windows application is making it Windows 2000, NT, XP or Vista compatible (marking the unicode flag in the compiled binary). Windows 95 and 98 are not unicode compatible, and doesn't display well this kind of applications. blitzMax is outputing unicode chars but seems to not have this flag set.
there's also a Microsoft utility for developers, that solves this unicode-ansi compatibility issue, enabling the binaries to be compatible with windows 98 and NT based windows. this tool is called Microsoft Layer for Unicode (MSLU), and can be downloaded for free. The bad news is that this utility is a DLL that has to be deployed with your final application, but it solves all the unicode issues on applications that have the unicode flag set to true, and are run under Windows 95 or 98.