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('рф')]);
精彩评论