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" ( ő 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.)


|