#1 2015-02-08 12:23:51

rabirabi
Member
Registered: 2015-02-08
Posts: 2

get TWinHTTP.get result in unicode

Greetings..
I am a big fan of this opensource project. I am a delphi student and came across a problem while trying to send get request using TWinHttp. The result is in rawbytestring which cannot show unicode characters.
The same result can be obtained using IdHttp.get() method, but it is very slow in comparison to TWinHttp. How can I get the unicode characters in the result. I am using Delphi XE6.

Offline

#2 2015-02-08 16:29:36

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: get TWinHTTP.get result in unicode

There is no "Unicode" in HTTP.
HTTP send some raw bytes over the wire, and the format is indicated in the HTTP header itself.
Most of the time, it is UTF-8.

Use UTF8ToString() to convert the rawbytestring returned by TWinHTTP, or WinAnsiToUnicodeString() if the returned text is CP-1252 encoded.

Offline

#3 2015-02-09 12:31:33

rabirabi
Member
Registered: 2015-02-08
Posts: 2

Re: get TWinHTTP.get result in unicode

UTFToString() worked as expected. Thanks alot.

Offline

Board footer

Powered by FluxBB