2010-11-26 151 views
7

如何我可以从网上得到一个网页,如果我有西里尔字母域名(HTTP://президент.рф/)用Delphi 7西里尔字母域名

谢谢!

回答

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

德尔福与WideString的7变化的UnicodeString – 2010-11-26 14:47:37

相关问题