开发者

Delphi. Show gotten with idHTTP.Get Unicode text in multilanguage Windows

I need your help. Please help me.

I have Delphi 2010

I try to idHTTP.Get a file with Unicode text (Russian开发者_开发技巧) from site into MemoryStream on English version of Windows 7.

Then I load this MemoryStream with Unicode text into, for example, Memo.

If I set the Russian language as "Language for non-Unicode programs" in Control Panel the text appear properly in Memo. But if I set Enlish - I get wrong characters (*$^#~!@).

How can I load Russian text in Unicode with idHTTP.Get from site and show it properly in any Windows (Chinese, English etc.)???

Thank you for help!!!


I suggest updating to a recent Delphi version that is Unicode enabled.

Update: It looks like the memorystream actually contains AnsiText in a specific code page instead of real Unicode text. You can declare an appropriate AnsiString variable with that codepage, load the text into that variable and then load the variable into the memo.

It is hard to tell more without seeing the real data.


TMemo expects Unicode (UTF-16 encoded) text. If you download the text using the version of TIdHTTP.Get() that fills a TStream, then you are downloading the raw (usually Ansi encoded) text, and then are responsible for manually decoding that to Unicode before then assigning that to the TMemo.

Assuming the webserver is specifying a correct charset for the text in the response headers, then use the version of TIdHTTP.Get() that returns a String instead. TIdHTTP will detect the charset and decode the raw data into Unicode for you, eg:

Memo1.Text := IdHTTP1.Get('http://addr_here');


  • Update to D2009 or higher
  • Use components that support unicode (I remember TMS offers some components)
  • Set the character set / code page correctly for the language you are using
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜