开发者

Cyrillic domain name

How I can get a page from internet, if I have cyrillic domain (http://президент.рф/) with Delphi 7开发者_StackOverflow.

Thanks!


I have written a punycode encoder/decoder available here:

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

usage:

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('рф')]);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜