Discussion:
convert http query result from byte stream to unicode
(too old to reply)
kombat
2007-05-15 05:09:51 UTC
Permalink
i have a small client that performs http queries and receives back
text (using wininet).
this text, when looked at in a browser, contains unicode characters.

when i do my http request i get back a byte stream, when i look at it
the english characters are good but the non-english one are not
readable.

what do i need to do in order to convert this correctly to a unicode
string ? a unicode string that will correctly represent these non-
english characters.

i tried using mlang.dll's DetectInputCodepage but that didn't help.

thank you
kombat
2007-05-15 06:17:17 UTC
Permalink
Post by kombat
i have a small client that performs http queries and receives back
text (using wininet).
this text, when looked at in a browser, contains unicode characters.
when i do my http request i get back a byte stream, when i look at it
the english characters are good but the non-english one are not
readable.
what do i need to do in order to convert this correctly to a unicode
string ? a unicode string that will correctly represent these non-
english characters.
i tried using mlang.dll's DetectInputCodepage but that didn't help.
thank you
solved
CA2T(str, CP_UTF8 );

just learned that ASCII can be seen as subset of UTF8, meaning the
byte-stream i got back was actually UTF-8 encoded although it seemed
like ASCII to the naked eye.
meaning it just needs to go through a UTF8 to Unicode (UTF-16)
decoder, which windows/atl provides.

Loading...