SFML community forums
Bindings - other languages => C => Topic started by: serg on May 31, 2020, 05:13:39 pm
-
Hi All
i'm on my way to make a text editor using CSFML
i've experienced an issue to get input from keyboard and draw utf text
removed by TS
please assist with my misunderstanding
thnx.
-
i've experienced an issue
Please describe it. Nobody wants to guess.
-
i've experienced an issue
Please describe it. Nobody wants to guess.
sorry. it was under the quote. is it possible for you to check it?
sfText_setUnicodeString(text, (sfUint32 *) wstr); // wrong: display the char but then override it with blank square
i see the proper wchat_t * wstr using cmd.exe and wcslen(wstr) returns the proper count of utf chars
so looks like i don't understand how to cast sfUint32 to wchar_t on Windows where wchar_t is 2 bytes long
and not 4 bytes to draw it correctly
how to pass whcar_t *wstr on Win10 to sfText_setUnicodeString() to get it working?
i've the same result using gcc 7.3 and clang 10 (msvc)
thanks.
-
i've experienced an issue
Please describe it. Nobody wants to guess.
and
dear sir
would you please be so kind to provide a short example how to add event.text.unicode to wchar_t *str and how to pass that str to sfText_setUnicodeString() ( where wchar_t is 2 byte long on Win10)
thnx.
-
A pointer cast on primitive types is never a good idea, it makes the compiler think that the pointed data is of another type than its actual type. There's no conversion at all, so it almost ends up in undefined behaviour.
sfEvent gives you a sfUint32 character, and sfText_setUnicodeString takes a const sfUint32*. Is there a good reason for storing your string as a wchar_t? If so, you'll have to convert using dedicated functions, as wchar_t uses UCS-2 encoding on Windows, and SFML gives you UTF-32 characters.
-
Is there a good reason for storing your string as a wchar_t?
text should be parsed using <string.h> f(x)
is there any way to parse UTF-32 string using C lang string functions and not char by char?
pls advice
thnx.
-
...
sfEvent gives you a sfUint32 character, and sfText_setUnicodeString takes a const sfUint32*. Is there a good reason for storing your string as a wchar_t? If so, you'll have to convert using dedicated functions, as wchar_t uses UCS-2 encoding on Windows, and SFML gives you UTF-32 characters.
so my solution here is to draw chars as UTF-32 and store another wchar_t array to parse it
thnx.
ps: big thanks for C_SFML. it's superb!
-
What do you mean with "parse"? What do you do with the text?
-
What do you mean with "parse"? What do you do with the text?
i meant working with strings (arrays) using wcsncmp(), wcstok() and so on
and i don't now how to do it with UTF-32 on windows
definetely it's offtopic here.
thnx