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