SFML community forums
Help => General => Topic started 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?
-
Which encoding does your text file use?
-
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
-
Anyone?
-
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.
-
So I have to read text from file, then convert to UTF-32 and use sfString_SetUnicodeText?
-
Yes.
-
Laurent could You post some code how to transfer UTF8 to UTF32 so it could be used in sfString_SetUnicodeText?
-
SFML (C++) contains such functions in the System module, you can copy them and translate them to C.
-
I'm looking at GitHub right now and I can't find it x_x Damn am I blind?
-
https://github.com/SFML/SFML/blob/master/include/SFML/System/Utf.inl#L276
-
Thanks.