utf8 helpers
utf8 helpers
http://sourceforge.net/p/irrlicht/patches/293/
Data tends to be in utf-8, platforms act natively in wchar. This is a much smaller implementation than Nalin's irrUString, yet it should be useful to many platforms.
Data tends to be in utf-8, platforms act natively in wchar. This is a much smaller implementation than Nalin's irrUString, yet it should be useful to many platforms.
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
Re: utf8 helpers
This look really interesting. Will extended characters will be stripped or converted (accented characters, etc)?
Also Irrlicht using mostly LATIN1 type fonts for display, displaying one of wchar will display correctly?
Also Irrlicht using mostly LATIN1 type fonts for display, displaying one of wchar will display correctly?
Re: utf8 helpers
I personally use it this way:
Data is in utf8 on disk. The TTF class takes stringw in its draw method. So on loading I convert from utf8 to wchar.
If you use bitmap fonts you need to have one with your symbols. All valid extended chars are converted.
Data is in utf8 on disk. The TTF class takes stringw in its draw method. So on loading I convert from utf8 to wchar.
If you use bitmap fonts you need to have one with your symbols. All valid extended chars are converted.
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
Re: utf8 helpers
This is really nice!
Re: utf8 helpers
Patch applied into trunk.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
Re: utf8 helpers
Wow Thanks! That's a great news. I'll use this version for my project now!
EDIT: Strange, it compile but I get a linker error.
I'm still using MSVC Express 2008. Something is missing in the IRR project? The library compiled, but using this function with the compiled library give this error.
irrString.h should contain some link to the new function?
EDIT: Strange, it compile but I get a linker error.
Code: Select all
>XML_Manager.obj : error LNK2001: symbole externe non résolu "void __cdecl irr::core::utf8ToWchar(char const *,wchar_t *,unsigned __int64)" (?utf8ToWchar@core@irr@@YAXPBDPA_W_K@Z)
irrString.h should contain some link to the new function?
Re: utf8 helpers
I have to add export defines to the new functions in irrString.h. I'll fix it today.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
Re: utf8 helpers
Thanks Hendu, I added manually the new commands and recompiled the DLL then used it again with my project and it seem to work. Compile, link. Have to check how to use the command properly now.
I have a crash every time I use it:
I define this:
I am assuming that I would get the converted string in the output variable. But got some kind of memory allocation error that create a crash. Each time the debugger point me to the core::utf8ToWchar() command.
I have a crash every time I use it:
I define this:
Code: Select all
//xml is from irrXML
core::stringc input=xml->getAttributeValue("str");
core::stringw output=L""
core::utf8ToWchar(input.c_str(),output,input.size());
Re: utf8 helpers
You're passing a stringw where wchar_t* is expected, and you're claiming the output buffer is input.size() bytes long, when it is 2/4 bytes long. So of course it crashes trying to write N bytes to a 2/4-sized buffer
Code: Select all
wchar_t out[200];
utf8ToWchar("test", out, 200);
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
Re: utf8 helpers
Thanks Hendu. Now it work just fine! Got my accents back!
That is a great addition to Irrlicht since we can read/write strings encoded in UTF8 now!
That is a great addition to Irrlicht since we can read/write strings encoded in UTF8 now!
Re: utf8 helpers
Problem with missing exports is fixed in trunk.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes