开发者

Cyrillic domain name

开发者 https://www.devze.com 2023-01-27 06:25 出处:网络
How I can get a page from internet, if I have cyrillic domain (http://президент.рф/) with Delphi 7开发者_StackOverflow.

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

精彩评论

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