Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Non ASCII characters  (Read 5207 times)

0 Members and 1 Guest are viewing this topic.

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Non ASCII characters
« on: July 06, 2011, 03:30:28 pm »
Hi, I'm from Poland and here we have special characters like:
ą,ę,ź,ż,ć,ó now i have a txt file where I have:
żźźżóóóóó
And of course when I'm trying to display it in SFML I get only óóóó, so I tried to add character set liek in tutorials:

sfUint32 zbior[] = {0x0104,0x0106,0x0118,0x0141,0x0143,0x00D3,0x015A,0x0179,0x017B,0x0105,0x0107,0x0119,0x0142,0x0144,0x00F3,0x015B,0x017A,0x017C,0x0};
   sfFont_CreateFromFile("arial.ttf",50,zbior);

And when I set this Font to string I get nothing displayed. Any solutions?
Should I convert all chars readed from file to sfUint32 array and use sfString_SetUnciodeText?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Non ASCII characters
« Reply #1 on: July 06, 2011, 03:36:21 pm »
Which encoding does your text file use?
Laurent Gomila - SFML developer

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Non ASCII characters
« Reply #2 on: July 06, 2011, 04:01:43 pm »
It doesn't really matters. Just let me know which one I should use when I'm using Notepad to save file, I can choose from four:
ASCII
Unicode
Unicode Big Endian
UTF-8

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Non ASCII characters
« Reply #3 on: July 07, 2011, 11:34:39 pm »
Anyone?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Non ASCII characters
« Reply #4 on: July 08, 2011, 07:50:10 am »
CSFML doesn't provide many functions to convert between encodings (unlike SFML), so you'll have to handle this yourself. Basically, you must choose an encoding for your file that you can easily read back in your code, and convert that to UTF-32 to use sfString_SetUnciodeText.
Laurent Gomila - SFML developer

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Non ASCII characters
« Reply #5 on: July 08, 2011, 12:45:10 pm »
So I have to read text from file, then convert to UTF-32 and use sfString_SetUnicodeText?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Non ASCII characters
« Reply #6 on: July 08, 2011, 01:26:45 pm »
Yes.
Laurent Gomila - SFML developer

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Non ASCII characters
« Reply #7 on: July 11, 2011, 11:22:19 am »
Laurent could You post some code how to transfer UTF8 to UTF32 so it could be used in sfString_SetUnicodeText?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Non ASCII characters
« Reply #8 on: July 11, 2011, 11:53:47 am »
SFML (C++) contains such functions in the System module, you can copy them and translate them to C.
Laurent Gomila - SFML developer

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Non ASCII characters
« Reply #9 on: July 12, 2011, 11:16:12 am »
I'm looking at GitHub right now and I can't find it x_x Damn am I blind?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Laurent Gomila - SFML developer

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Non ASCII characters
« Reply #11 on: July 12, 2011, 12:09:49 pm »
Thanks.