com.upokecenter.text.Idna

com.upokecenter.text.Idna

public final class Idna extends Object

Contains methods that implement Internationalized Domain Names in Applications (IDNA). IDNA enables using a wider range of letters, numbers, and certain other characters in domain names. This class implements the 2008 revision of IDNA, also known as IDNA2008.

The following summarizes the rules for domain names in IDNA2008; see RFC5890 for more information and additional terminology.

A domain name is divided into one or more strings separated by dots ("."), called labels. For IDNA2008's purposes, a valid label can be an NR-LDH label, an A-label, or a U-label.

An LDH label contains only basic uppercase letters, basic lowercase letters, basic digits, and/or "-", and neither begins nor ends with "-". For example, "exa-mple", "EXAMPLE", and "1example" are LDH labels, but not "-example".

An NR-LDH label is an LDH label whose third and fourth characters are not both "-". For example, "ex--ample" is not an NR-LDH label.

A U-label contains one or more characters outside the Basic Latin range (U+0000 to U+007F) and meets IDNA2008 requirements for labels with such characters. An example is "eá".

An A-label is an LDH label beginning with "xn--" where the letters can be any combination of basic upper-case and/or basic lower-case letters, and is convertible to a U-label. An example is "xn--e-ufa".

An XN-label is an LDH label beginning with "xn--" where the letters can be any combination of basic upper-case and/or basic lower-case letters.

NOTICE: While this class's source code is in the public domain, the class uses two internal classes, called NormalizationData and IdnaData, that include data derived from the Unicode Character Database. See the documentation for the NormalizerInput class for the permission notice for the Unicode Character Database.

Methods

Method Details

DecodeDomainName

public static String DecodeDomainName(String value)

Tries to encode each XN-label of the given domain name into Unicode. This method does not check the syntactic validity of the domain name before proceeding.

Parameters:

Returns:

Throws:

EncodeDomainName

public static String EncodeDomainName(String value)

Tries to encode each label of a domain name with code points outside the Basic Latin range (U+0000 to U+007F) into an XN-label. This method does not check the syntactic validity of the domain name before proceeding.

Parameters:

Returns:

Throws:

IsValidDomainName

public static boolean IsValidDomainName(String str, boolean lookupRules)

Determines whether the given string is a domain name containing only U-labels, A-labels, NR-LDH labels, or any combination of these, separated by dots (".").

Parameters:

Returns:

Throws:

Back to MailLib start page.