西里尔语域名 [英] Cyrillic domain name

查看:127
本文介绍了西里尔语域名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



谢谢!

如果我用Delphi 7的cyrillic域(http://президент.рф/) p>

解决方案

我在这里写了一个punycode编码器/解码器:



a href =http://code.google.com/p/delphionrails/source/browse/trunk/src/dorPunyCode.pas =noreferrer> http://code.google.com/p/delphionrails/ source / browse / trunk / src / dorPunyCode.pas



用法:

 函数PEncode(const str:UnicodeString):AnsiString; 
var
len:红衣主教;
begin
结果:='';
if(PunycodeEncode(Length(str),PPunyCode(str),len)= pcSuccess)和(Length(str)+ 1 - len)then
begin
SetLength ,len);
PunycodeEncode(Length(str),PPunyCode(str),len,PByte(Result));
结果:='xn--'+结果;
end else
结果:= AnsiString(str);
结束

格式('http://%s.%s',[PEncode('президент'),PEncode('рф')]);


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

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

这篇关于西里尔语域名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆