SFML community forums

Bindings - other languages => C => Topic started by: Timofeyka on November 14, 2021, 01:26:08 pm

Title: Russian text in sfText
Post by: Timofeyka on November 14, 2021, 01:26:08 pm
Hello! :)

I am creating a game using C SFML (task), but I do not understand how to display Russian text in sfText.

I tried to change the encoding - nothing changes.  >:(
The font fully supports everything.

Question - how do I display the Russian language correctly in sfText?
Thank you in advance!
(by default, I have UTF-8 encoding set, but I tried to use ASCII and others)
Title: Re: Russian text in sfText
Post by: eXpl0it3r on November 15, 2021, 04:07:57 pm
You'll need to (somehow) construct an array of sfUint32's which you then can pass to the sfText_setUnicodeString function. Handling unicode strings in C seems even more annoying that in C++.
If you have C11, then you might be able to make use of <uchar.h> and convert to sfUint32* somehow, see also: https://stackoverflow.com/a/527307/1034248
Title: Re: Russian text in sfText
Post by: Timofeyka on November 19, 2021, 09:09:47 pm
Thanks, it works! But there is one but.

I didn't check if this is the case with the usual setString in CFML, but when I use set Unicode String for my counter, not normal text begin to appear.
(https://i.ibb.co/Y2pXJFZ/image.png)