(solved)utf-8 to utf-16

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.

(solved)utf-8 to utf-16

Postby utunnels » Tue Apr 24, 2012 7:03 am

I wonder if there's a direct way that converts utf-8 to unicode. Because some method like setWindowCaption use irr::core::stringw, while strings produced by xml reader can be either stringc or stringw.

If not, maybe I should avoid the trouble and save all xml files using unicode.
Last edited by utunnels on Tue Apr 24, 2012 2:15 pm, edited 2 times in total.
utunnels
 
Posts: 37
Joined: Thu Apr 05, 2012 2:52 pm

Re: utf-8 to unicode

Postby hendu » Tue Apr 24, 2012 8:25 am

unicode is not a format, it's a general name. utf-8 is unicode.
hendu
 
Posts: 1551
Joined: Sat Dec 18, 2010 12:53 pm

Re: utf-8 to unicode

Postby utunnels » Tue Apr 24, 2012 1:11 pm

(face palm)

Well, I think you got what I meant. :P
In many text editor the encoding option unicode and unicode big endian actually means utf-16le and utf-16be.

The question is, if I have a utf-8 string, how do I convert it to utf-16?
utunnels
 
Posts: 37
Joined: Thu Apr 05, 2012 2:52 pm

Re: utf-8 to utf-16

Postby CuteAlien » Tue Apr 24, 2012 1:49 pm

Hm, if you just want to copy from char to widechar you can do that with the irrlicht strings directly. You can just pass a stringc to a stringw (at least in the constructor, would have to look-up docs if assignement is also possible.. probably is).

But if you actually have real utf-8, meaning you use it to have for example cyrillic characters in utf-8, then you need a real conversions.
My way is usually like this: http://www.michaelzeilfelder.de/irrlich ... bleComplex
IRC: #irrlicht on irc.freenode.net
My patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Games with Irrlicht: http://www.irrgheist.com/
News: http://www.reddit.com/r/irrlicht/
User avatar
CuteAlien
Admin
 
Posts: 5349
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: utf-8 to utf-16

Postby utunnels » Tue Apr 24, 2012 2:00 pm

But if you actually have real utf-8, meaning you use it to have for example cyrillic characters in utf-8, then you need a real conversions.
My way is usually like this: ...

Thank you. That is what I want to do.
utunnels
 
Posts: 37
Joined: Thu Apr 05, 2012 2:52 pm


Return to Beginners Help

Who is online

Users browsing this forum: Google [Bot] and 1 guest