西里尔文域名

use*_*503 7 delphi

如果我有Delphi 7的西里尔字母域(http://президент.рф/),我如何从互联网上获取页面.

谢谢!

Hen*_*est 10

我在这里写了一个punycode编码器/解码器:

http://code.google.com/p/delphionrails/source/browse/trunk/src/dorPunyCode.pas

用法:

function PEncode(const str: UnicodeString): AnsiString;
var
  len: Cardinal;
begin
  Result := '';
  if (PunycodeEncode(Length(str), PPunyCode(str), len) = pcSuccess) and (Length(str) + 1 <> len) then
  begin
    SetLength(Result, len);
    PunycodeEncode(Length(str), PPunyCode(str), len, PByte(Result));
    Result := 'xn--' + Result;
  end else
    Result := AnsiString(str);
end;

Format('http://%s.%s', [PEncode('?????????'), PEncode('??')]);
Run Code Online (Sandbox Code Playgroud)