SFML community forums

Help => General => Topic started by: darekg11 on July 06, 2011, 03:30:28 pm

Title: Non ASCII characters
Post by: darekg11 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?
Title: Non ASCII characters
Post by: Laurent on July 06, 2011, 03:36:21 pm
Which encoding does your text file use?
Title: Non ASCII characters
Post by: darekg11 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
Title: Non ASCII characters
Post by: darekg11 on July 07, 2011, 11:34:39 pm
Anyone?
Title: Non ASCII characters
Post by: Laurent 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.
Title: Non ASCII characters
Post by: darekg11 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?
Title: Non ASCII characters
Post by: Laurent on July 08, 2011, 01:26:45 pm
Yes.
Title: Non ASCII characters
Post by: darekg11 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?
Title: Non ASCII characters
Post by: Laurent 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.
Title: Non ASCII characters
Post by: darekg11 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?
Title: Non ASCII characters
Post by: Laurent on July 12, 2011, 11:37:02 am
https://github.com/SFML/SFML/blob/master/include/SFML/System/Utf.inl#L276
Title: Non ASCII characters
Post by: darekg11 on July 12, 2011, 12:09:49 pm
Thanks.