nsIIDNService 编辑

netwerk/dns/nsIIDNService.idlScriptable This interface provides support for Internationalized Domain Names, including methods for manipulating IDN hostnames according to IETF specification. Inherits from: nsISupports Last changed in Gecko 1.9 (Firefox 3)

Implemented by: @mozilla.org/network/idn-service;1 as a service:

var idnService = Components.classes["@mozilla.org/network/idn-service;1"]
                 .getService(Components.interfaces.nsIIDNService);

Method overview

AUTF8String convertACEtoUTF8(in ACString input);
AUTF8String convertToDisplayIDN(in AUTF8String input, out boolean isASCII);
ACString convertUTF8toACE(in AUTF8String input);
boolean isACE(in ACString input);
AUTF8String normalize(in AUTF8String input);

Methods

convertACEtoUTF8()

Converts an ACE (ASCII Compatible Encoding) hostname into Unicode format, returning a UTF-8 format string. This combines two operations: running the RFC 3490 "ToUnicode" operation on the original string, then converting the resulting Unicode string into UTF-8 format.

AUTF8String convertACEtoUTF8(
  in ACString input
);
Parameters
input
The ACE encoded hostname to convert into UTF-8 format.
Return value

The UTF-8 encoded equivalent of the hostname.

convertToDisplayIDN()

Normalizes a hostname into UTF-8 format if the hostname is in the IDN whitelist. If the hostname isn't in the whitelist, it's converted into ACE format. The resulting string is useful for display purposes, and ensures that the encoding is consistent with nsIURI.GetHost().

AUTF8String convertToDisplayIDN(
  in AUTF8String input,
  out boolean isASCII
);
Parameters
input
The string to convert to display format.
isASCII
On return, this is set to true if the result is ASCII or ACE encoded; otherwise it's false.
Return value

The display formatted hostname.

convertUTF8toACE()

Converts the specified hostname from UTF-8 to ACE format, using the IDNA "ToASCII" algorithm.

ACString convertUTF8toACE(
  in AUTF8String input
);
Parameters
input
The hostname to convert to ACE format.
Return value

The ACE encoded version of the hostname.

isACE()

Determines whether or not the specified hostname is ACE encoded.

boolean isACE(
  in ACString input
);
Parameters
input
The string to check.
Return value

Returns true if the specified string is ACE encoded; otherwise, returns false.

normalize()

Performs the Unicode normalization needed for hostnames in IDN. This is useful if you need to normalize a hostname separately from converting it to display format.

AUTF8String normalize(
  in AUTF8String input
);
Parameters
input
The hostname to normalize.
Return value

The normalized hostname.

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:117 次

字数:5632

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文