|
Allegro 5 Unicode textDraw |
APrince
Member #12,698
March 2011
|
Hi, I've been trying for very long time to somehow manage to print wchart_t string to the screen. This part of documentation if kind of misty, so I had a lot of problems with it. After several hours I found this note: Quote: There are problems with UTF-8 string literals under MSVC. Does it mean that it doesn't work in Visual Studio at all? All i'd like to do is to print simple wchar_t array to the screen. No loading from config files or whatever... Thanks a lot. |
gnolam
Member #2,030
March 2002
|
wchar_t isn't UTF-8. -- |
SiegeLord
Member #7,827
October 2006
|
From stuff I read, using UTF-8 string literals is impossible in MSVC. A5 even disables the example that has those literals because no solution was found. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Elias
Member #358
May 2000
|
Well, if you have wchar_t, all you need to do is convert it to UTF8. I wouldn't know how to get string literals into wchar_t or how to convert wchar_t to UTF8 - both of those are done outside of Allegro. -- |
jmasterx
Member #11,410
October 2009
|
Agui GUI API -> https://github.com/jmasterx/Agui |
Elias
Member #358
May 2000
|
Yeah, so the next step is to get a string literal into an LPCWSTR. I guess you should use the UTF8 BOM and use L"" instead of "" for the string literal, supposedly making VC convert from UTF8 to UTF16 which WideCharToMultiByte can convert back to UTF8 to be passed to Allegro. -- |
APrince
Member #12,698
March 2011
|
Well I'm not fixed to wchar_t, it just seemed to me the best way to ensure some portability (if I decided to port the application to Linux for whatever reason). The thing is there's another library built atop of the Allegro and must not be dependent on it. So the better way may be to define my own string type (abstract class) which could have conversion methods and than make a child for Allegro which would inherit and override those... Or do you suppose anything rather easier? |
Elias
Member #358
May 2000
|
The issue you quoted only concerns string literals in your source code. There should be no problem if you load the strings in another way (reading from a file). And wchar_t all by itself isn't really portable as it depends on the current locale. If you don't call setlocale() in your program then wchar_t is limited to 7-bit ASCII since the default locale ("C" locale) of libc supports nothing else. (That's my understanding at least.) -- |
|