converting to utf8?

W

whatdoineed2do

hi,

i've not done much i18n stuff before but i was wondering how, if given
a string (encoded as russian or kanji mb) how i would get this
converted to utf8. i'm working with forte compiler on solaris

i've something like:

const char* s = "...."; // some russian/kanji encoded
locale l("en_US.UTF8");
wstringstream cnv;
cnv.imbue(l);
cnv << s;
cout << "orig='" << s << "'\nconverted='" << cnv.str() << "'" <<
endl;

but this doesnt work. can anyone give me some advise?

thanks
ray
 
J

James Kanze

i've not done much i18n stuff before but i was wondering how, if given
a string (encoded as russian or kanji mb) how i would get this
converted to utf8. i'm working with forte compiler on solaris
i've something like:
const char* s = "...."; // some russian/kanji encoded
locale l("en_US.UTF8");
wstringstream cnv;
cnv.imbue(l);
cnv << s;
cout << "orig='" << s << "'\nconverted='" << cnv.str() << "'" <<
endl;
but this doesnt work. can anyone give me some advise?

The locale is only used for conversion when writing to or
reading from a file. A priori, you'll have to pass through
wchar, and use two different locales (in fact, two different
codecvt<wchar> facets).
 
W

whatdoineed2do

hi,

i've not done much i18n stuff before but i was wondering how, if given
a string (encoded as russian or kanji mb) how i would get this
converted to utf8. i'm working with forte compiler on solaris

i've something like:

const char* s = "...."; // some russian/kanji encoded
locale l("en_US.UTF8");
wstringstream cnv;
cnv.imbue(l);
cnv << s;
cout << "orig='" << s << "'\nconverted='" << cnv.str() << "'" <<
endl;

but this doesnt work. can anyone give me some advise?

thanks
ray

i managed to figure this out; using iconv(3C) -- this provides the
codepage conversion that i needed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top