How to create UTF-8 file?

Previous topic - Next topic



I have this code:

Code (glbasic) Select
LOCAL a$="Test... writte this characters: áéíóúñ"
//Create a text file anf writte a$ content.
OPENFILE(1, "test.txt", FALSE)
WRITESTR 1, a$+"\r\n"

My problem is with the special characters "áéíóúñ". When I open it with a text program I get chinese characters. I think is a encoding matter. How can I create the text file with UTF-8 encode?


You could be using the wrong editor!

I get Test... writte this characters: áéíóúñ in Notepad...


Thanks for testing MrTAToad. I have the same problem with notepad. Perhaps is my computer.... I'll check this out and post the solution here if I find it.


Can GLBasic save UTF-8?

Otherwise you will have to do some reading here I guess :-)


Not natively no, but it couldn't be too hard to write a routine :)

Kitty Hello

Sorry for the delay ;)
I wrote a tiny library that can convert to/from utf-8:



I'd want to have some library that can display CJK characters with TTF Fonts, if there's something like this or a paid DLC, I'd buy it.

The Hangul example works for diaply bitmap fonts well, but if GLB wirks with unicode directly, it'll be a big bonus.

Kitty Hello

I think, the TTF routines should go into GLBasic directly, and then we might be able to render TTF fonts using UTF-8 charset. But it's quite some work. Alternatively we might add a TTF library wrapper...