How to create UTF-8 file?

Previous topic - Next topic

Alex_R

Hi!

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"
WRITELINE 1,a$
CLOSEFILE 1


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?

MrTAToad

You could be using the wrong editor!

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

Alex_R

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.

Moru

Can GLBasic save UTF-8?

Otherwise you will have to do some reading here I guess :-)
http://en.wikipedia.org/wiki/UTF-8
http://en.wikipedia.org/wiki/Byte_order_mark

MrTAToad

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:
http://www.glbasic.com/forum/index.php?topic=11367.0

Youkaisan

Hi,

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...