GLBasic forum

Main forum => GLBasic - en => Topic started by: Alex_R on 2012-Jun-21

Title: How to create UTF-8 file?
Post by: Alex_R on 2012-Jun-21
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?
Title: Re: How to create UTF-8 file?
Post by: MrTAToad on 2012-Jun-21
You could be using the wrong editor!

I get Test... writte this characters: áéíóúñ in Notepad...
Title: Re: How to create UTF-8 file?
Post by: Alex_R on 2012-Jun-21
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.
Title: Re: How to create UTF-8 file?
Post by: Moru on 2012-Jun-21
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
Title: Re: How to create UTF-8 file?
Post by: MrTAToad on 2012-Jun-21
Not natively no, but it couldn't be too hard to write a routine :)
Title: Re: How to create UTF-8 file?
Post by: Kitty Hello on 2019-Dec-10
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
Title: Re: How to create UTF-8 file?
Post by: Youkaisan on 2019-Dec-11
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.
Title: Re: How to create UTF-8 file?
Post by: Kitty Hello on 2019-Dec-31
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...