西里尔字母域名
答
我已经写了可使用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('рф')]);
德尔福与WideString的7变化的UnicodeString – 2010-11-26 14:47:37