Skip to content

Most visited

Recently visited

navigation
Added in API level 9

IDN

public final class IDN
extends Object

java.lang.Object
   ↳ java.net.IDN


Converts internationalized domain names between Unicode and the ASCII Compatible Encoding (ACE) representation.

See RFC 3490 for full details.

Summary

Constants

int ALLOW_UNASSIGNED

When set, allows IDN to process unassigned unicode points.

int USE_STD3_ASCII_RULES

When set, ASCII strings are checked against RFC 1122 and RFC 1123.

Public methods

static String toASCII(String input)

Equivalent to toASCII(input, 0).

static String toASCII(String input, int flags)

Transform a Unicode String to ASCII Compatible Encoding String according to the algorithm defined in RFC 3490.

static String toUnicode(String input, int flags)

Translates a string from ASCII Compatible Encoding (ACE) to Unicode according to the algorithm defined in RFC 3490.

static String toUnicode(String input)

Equivalent to toUnicode(input, 0).

Inherited methods

From class java.lang.Object

Constants

ALLOW_UNASSIGNED

Added in API level 9
int ALLOW_UNASSIGNED

When set, allows IDN to process unassigned unicode points.

Constant Value: 1 (0x00000001)

USE_STD3_ASCII_RULES

Added in API level 9
int USE_STD3_ASCII_RULES

When set, ASCII strings are checked against RFC 1122 and RFC 1123.

Constant Value: 2 (0x00000002)

Public methods

toASCII

Added in API level 9
String toASCII (String input)

Equivalent to toASCII(input, 0).

Parameters
input String: the Unicode name
Returns
String the ACE name
Throws
IllegalArgumentException if input does not conform to RFC 3490

toASCII

Added in API level 9
String toASCII (String input, 
                int flags)

Transform a Unicode String to ASCII Compatible Encoding String according to the algorithm defined in RFC 3490.

If the transformation fails (because the input is not a valid IDN), an exception will be thrown.

This method can handle either an individual label or an entire domain name. In the latter case, the separators are: U+002E (full stop), U+3002 (ideographic full stop), U+FF0E (fullwidth full stop), and U+FF61 (halfwidth ideographic full stop). All of these will become U+002E (full stop) in the result.

Parameters
input String: the Unicode name
flags int: 0, ALLOW_UNASSIGNED, USE_STD3_ASCII_RULES, or ALLOW_UNASSIGNED | USE_STD3_ASCII_RULES
Returns
String the ACE name
Throws
IllegalArgumentException if input does not conform to RFC 3490

toUnicode

Added in API level 9
String toUnicode (String input, 
                int flags)

Translates a string from ASCII Compatible Encoding (ACE) to Unicode according to the algorithm defined in RFC 3490.

Unlike toASCII, this transformation cannot fail.

This method can handle either an individual label or an entire domain name. In the latter case, the separators are: U+002E (full stop), U+3002 (ideographic full stop), U+FF0E (fullwidth full stop), and U+FF61 (halfwidth ideographic full stop).

Parameters
input String: the ACE name
flags int: 0, ALLOW_UNASSIGNED, USE_STD3_ASCII_RULES, or ALLOW_UNASSIGNED | USE_STD3_ASCII_RULES
Returns
String the Unicode name

toUnicode

Added in API level 9
String toUnicode (String input)

Equivalent to toUnicode(input, 0).

Parameters
input String: the ACE name
Returns
String the Unicode name
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.