Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: UNICODE I/O
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 11 Topic 44152 of 48417
Post > Topic >>

Re: UNICODE I/O

by Ali <ali.baharev@[EMAIL PROTECTED] > Mar 27, 2008 at 10:20 AM

On m=C3=A1rc. 27, 16:48, Ali <ali.baha...@[EMAIL PROTECTED]
> wrote:
> On m=C3=A1rc. 27, 15:06, Michael DOUBEZ <michael.dou...@[EMAIL PROTECTED]
> wrote:
>
>
>
> > Ali a =C3=A9crit :
>
> > > On m=C3=A1rc. 27, 13:33, Michael DOUBEZ <michael.dou...@[EMAIL PROTECTED]
>
wrote=
:
> > >> Ali a =C3=A9crit :
>
> > >>> Well, the example string L"=C3=B5=C3=BB=C3=AD=C3=95=C3=9B=C3=8D"
is =
not displayed correctly in my
> > >>> previous e-mail (even though UTF-8 char encoding is used).
> > >> That is not what the header of the mail says:
> > >> First mail:
> > >> Content-Type: text/plain; charset=3DISO-8859-2
> > >> Second mail:
> > >> Content-Type: text/plain; charset=3DISO-8859-1
>
> > >> Michael
>
> > > Dear Michael,
>
> > > This is mysterious. The web page i have sent the mail from uses
UTF-8.=

> > > I have no idea how the messages became ISO-8859-1 and 8859-2, and i
do=

> > > not know how to control the encoding of the messages.
>
> > > A good canditate for trouble making is letter o" ( &#337; in HTML
> > > UTF-8). It is displayed correctly in the IDE is wstring s, but is
not
> > > written to the file.
>
> > I guess your problem with writing to a file is the same as writing the
> > post :)
>
> > Have you tried to imbue the local:
>
> > typedef std::codecvt_byname<wchar_t, char, std::mbstate_t> WCvt;
> > const std::locale unicode(std::locale("C"), new WCvt("UCS2"));
>
> > int main() {
> >         wofstream out;
> >         out.rdbuf()->pubimbue(unicode);
> >         out.open(L"log");
> >         if (!out)
> >                 exit(127);
> >         wstring s(L"=C5=91=C5=B1=C3=AD=C5=90=C5=B0=C3=8D");
> >         out << s << endl;
> >         out.close();
> >         return 0;
>
> > }
>
> > Michael
>
> Dear Micheal,
>
> Just one more question. How can i convert (preferably using C++ STL)
> an UTF-16 wstring to an UTF-8 array of char-s, needed for sqlite3?
>
> I guess the solution begins with something similar to the lines
>
> typedef std::codecvt_byname<wchar_t, char, std::mbstate_t> WCvt;
> const std::locale unicode(std::locale("C"), new WCvt("UCS2"));
>
> You wrote but i do not undearstand them.
>
> Many thanks,
>
> Ali

The size_t wcstombs(char *s, const wchar_t *pwcs, size_t n) looks like
the function i need, LC_CTYPE should be changed to tell the function i
would like the output in UTF-8.

However i failed to change LC_CTYPE. I tried setlocale(LC_CYTPE,
"en_US.utf8") and variants but none of them worked (MS VS2005). How
shell i do this?

(I am aware of function WideCharToMultiByte and it works fine but this
is an MS function, i would prefer a standard function.)
 




 11 Posts in Topic:
UNICODE I/O
Ali <ali.baharev@[EMAI  2008-03-27 05:12:14 
Re: UNICODE I/O
Ali <ali.baharev@[EMAI  2008-03-27 05:17:27 
Re: UNICODE I/O
Michael DOUBEZ <michae  2008-03-27 13:33:39 
Re: UNICODE I/O
Ali <ali.baharev@[EMAI  2008-03-27 05:50:45 
Re: UNICODE I/O
Michael DOUBEZ <michae  2008-03-27 15:06:39 
Re: UNICODE I/O
Michael DOUBEZ <michae  2008-03-27 15:11:03 
Re: UNICODE I/O
Tobias Blomkvist <TB@[  2008-03-27 14:40:19 
Re: UNICODE I/O
Ali <ali.baharev@[EMAI  2008-03-27 08:48:21 
Re: UNICODE I/O
Ali <ali.baharev@[EMAI  2008-03-27 10:20:20 
Re: UNICODE I/O
Michael DOUBEZ <michae  2008-03-28 11:12:16 
Re: UNICODE I/O
Michael DOUBEZ <michae  2008-03-28 11:14:12 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 9:29:46 CST 2008.