Author Topic: How to create UTF-8 file?  (Read 1696 times)

Offline Alex_R

  • Mr. Polyvector
  • ***
  • Posts: 238
    • View Profile
    • Axro Digital
How to create UTF-8 file?
« 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?
« Last Edit: 2012-Jun-21 by Alex_R »

MrTAToad

  • Guest
Re: How to create UTF-8 file?
« Reply #1 on: 2012-Jun-21 »
You could be using the wrong editor!

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

Offline Alex_R

  • Mr. Polyvector
  • ***
  • Posts: 238
    • View Profile
    • Axro Digital
Re: How to create UTF-8 file?
« Reply #2 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.

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1787
    • View Profile
    • Homepage
Re: How to create UTF-8 file?
« Reply #3 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

MrTAToad

  • Guest
Re: How to create UTF-8 file?
« Reply #4 on: 2012-Jun-21 »
Not natively no, but it couldn't be too hard to write a routine :)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10745
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: How to create UTF-8 file?
« Reply #5 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

Offline Youkaisan

  • Community Developer
  • Mr. Drawsprite
  • ******
  • Posts: 60
    • View Profile
Re: How to create UTF-8 file?
« Reply #6 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.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10745
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: How to create UTF-8 file?
« Reply #7 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...