Boost logo

Boost Users :

From: Andrea Denzler (andrea_at_[hidden])
Date: 2008-08-07 10:21:31


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_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] Per conto di Cory Nelson
Inviato: giovedì 7 agosto 2008 15.27
A: boost-users_at_[hidden]
Oggetto: Re: [Boost-users] about UTF8 to UNICODE

On Thu, Aug 7, 2008 at 2:21 AM, Ken zhang <kennir_at_[hidden]> 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?
>

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<unicode::utf8, unicode::wchar_encoding>(u8, wc);

-- 
Cory Nelson
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net