about UTF8 to UNICODE

Hello I hava a UTF8 string reading from TinyXML, I want convert to a Unicode string (wchar_t) for some reasons, How can convert it by boost? Thanks Kenneth.Sh

On Thu, Aug 7, 2008 at 2:21 AM, Ken zhang
Hello
I hava a UTF8 string reading from TinyXML, I want convert to a Unicode string (wchar_t) for some reasons, How can convert it by boost?
Boost doesn't have anything to do this. I've got some code here you can use:
http://svn.int64.org/svnroot/int64/snips/unicode.hpp
std::string u8;
std::wstring wc;
unicode::transcode

I'm using ICU (because I needed for boost regex to work with unicode):
UConverter *pConverterUTF8;
UErrorCode nUError;
// open converter
nUError = U_ZERO_ERROR;
pConverterUTF8=ucnv_open("utf-8",&nUError);
// do conversions
mystring = UnicodeString(utf8,strlen(utf8),pConverterUTF8,&nUError);
// close converter
ucnv_close(pConverterUTF8);
Handling Unicode has more to do than just conversion :(, but ICU offers many
functions.
Andrea
-----Messaggio originale-----
Da: boost-users-bounces@lists.boost.org
[mailto:boost-users-bounces@lists.boost.org] Per conto di Cory Nelson
Inviato: giovedì 7 agosto 2008 15.27
A: boost-users@lists.boost.org
Oggetto: Re: [Boost-users] about UTF8 to UNICODE
On Thu, Aug 7, 2008 at 2:21 AM, Ken zhang
Hello
I hava a UTF8 string reading from TinyXML, I want convert to a Unicode string (wchar_t) for some reasons, How can convert it by boost?
Boost doesn't have anything to do this. I've got some code here you can
use:
http://svn.int64.org/svnroot/int64/snips/unicode.hpp
std::string u8;
std::wstring wc;
unicode::transcode

Ken zhang wrote:
Hello
I hava a UTF8 string reading from TinyXML, I want convert to a Unicode string (wchar_t) for some reasons, How can convert it by boost?
It's not a public Boost API but boost/regex/pending/unicode_iterator.hpp contains several iterator classes that would help with this (try using u8_to_u32_iterator to convert to 32-bit code points). HTH, John.

Hi Dear all
I have implemented a function do convertion myself...
Thanks very much.
Yours Kenneth.Sh
2008/8/7 John Maddock
Ken zhang wrote:
Hello
I hava a UTF8 string reading from TinyXML, I want convert to a Unicode string (wchar_t) for some reasons, How can convert it by boost?
It's not a public Boost API but boost/regex/pending/unicode_iterator.hpp contains several iterator classes that would help with this (try using u8_to_u32_iterator to convert to 32-bit code points).
HTH, John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Best Regards, Ken Zhang Greatelsoft Co., Ltd. mailto:ken@greatelsoft.com http://www.greatelsoft.com M/P:0086-1350-191-6596

There the serialization library implements code to do this. You'd have to look for it though.
Robert Ramey
"Ken zhang"
participants (5)
-
Andrea Denzler
-
Cory Nelson
-
John Maddock
-
Ken zhang
-
Robert Ramey