|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.icu.text.IDNA
public abstract class IDNA
Abstract base class for IDNA processing. See http://www.unicode.org/reports/tr46/ and http://www.ietf.org/rfc/rfc3490.txt
The IDNA class is not intended for public subclassing.
The non-static methods implement UTS #46 and IDNA2008. IDNA2008 is implemented according to UTS #46, see getUTS46Instance().
The static methods implement IDNA2003.
IDNA2003 API Overview:
The static IDNA API methods implement the IDNA protocol as defined in the IDNA RFC. The draft defines 2 operations: ToASCII and ToUnicode. Domain labels containing non-ASCII code points are required to be processed by ToASCII operation before passing it to resolver libraries. Domain names that are obtained from resolver libraries are required to be processed by ToUnicode operation before displaying the domain name to the user. IDNA requires that implementations process input strings with Nameprep, which is a profile of Stringprep , and then with Punycode. Implementations of IDNA MUST fully implement Nameprep and Punycode; neither Nameprep nor Punycode are optional. The input and output of ToASCII and ToUnicode operations are Unicode and are designed to be chainable, i.e., applying ToASCII or ToUnicode operations multiple times to an input string will yield the same result as applying the operation once. ToUnicode(ToUnicode(ToUnicode...(ToUnicode(string)))) == ToUnicode(string) ToASCII(ToASCII(ToASCII...(ToASCII(string))) == ToASCII(string).
Nested Class Summary | |
---|---|
static class |
IDNA.Error
IDNA error bit set values. |
static class |
IDNA.Info
Output container for IDNA processing errors. |
Field Summary | |
---|---|
static int |
ALLOW_UNASSIGNED
Option to allow unassigned code points in domain names and labels. |
static int |
CHECK_BIDI
IDNA option to check for whether the input conforms to the BiDi rules. |
static int |
CHECK_CONTEXTJ
IDNA option to check for whether the input conforms to the CONTEXTJ rules. |
static int |
DEFAULT
Default options value: None of the other options are set. |
static int |
NONTRANSITIONAL_TO_ASCII
IDNA option for nontransitional processing in ToASCII(). |
static int |
NONTRANSITIONAL_TO_UNICODE
IDNA option for nontransitional processing in ToUnicode(). |
static int |
USE_STD3_RULES
Option to check whether the input conforms to the STD3 ASCII rules, for example the restriction of labels to LDH characters (ASCII Letters, Digits and Hyphen-Minus). |
Constructor Summary | |
---|---|
protected |
IDNA()
Deprecated. This API is ICU internal only. |
Method Summary | |
---|---|
protected static void |
addError(IDNA.Info info,
IDNA.Error error)
Deprecated. This API is ICU internal only. |
protected static void |
addLabelError(IDNA.Info info,
IDNA.Error error)
Deprecated. This API is ICU internal only. |
static int |
compare(StringBuffer s1,
StringBuffer s2,
int options)
IDNA2003: Compare two IDN strings for equivalence. |
static int |
compare(String s1,
String s2,
int options)
IDNA2003: Compare two IDN strings for equivalence. |
static int |
compare(UCharacterIterator s1,
UCharacterIterator s2,
int options)
IDNA2003: Compare two IDN strings for equivalence. |
static StringBuffer |
convertIDNToASCII(StringBuffer src,
int options)
IDNA2003: Convenience function that implements the IDNToASCII operation as defined in the IDNA RFC. |
static StringBuffer |
convertIDNToASCII(String src,
int options)
IDNA2003: Convenience function that implements the IDNToASCII operation as defined in the IDNA RFC. |
static StringBuffer |
convertIDNToASCII(UCharacterIterator src,
int options)
IDNA2003: Convenience function that implements the IDNToASCII operation as defined in the IDNA RFC. |
static StringBuffer |
convertIDNToUnicode(StringBuffer src,
int options)
IDNA2003: Convenience function that implements the IDNToUnicode operation as defined in the IDNA RFC. |
static StringBuffer |
convertIDNToUnicode(String src,
int options)
IDNA2003: Convenience function that implements the IDNToUnicode operation as defined in the IDNA RFC. |
static StringBuffer |
convertIDNToUnicode(UCharacterIterator src,
int options)
IDNA2003: Convenience function that implements the IDNToUnicode operation as defined in the IDNA RFC. |
static StringBuffer |
convertToASCII(StringBuffer src,
int options)
IDNA2003: This function implements the ToASCII operation as defined in the IDNA RFC. |
static StringBuffer |
convertToASCII(String src,
int options)
IDNA2003: This function implements the ToASCII operation as defined in the IDNA RFC. |
static StringBuffer |
convertToASCII(UCharacterIterator src,
int options)
IDNA2003: This function implements the ToASCII operation as defined in the IDNA RFC. |
static StringBuffer |
convertToUnicode(StringBuffer src,
int options)
IDNA2003: This function implements the ToUnicode operation as defined in the IDNA RFC. |
static StringBuffer |
convertToUnicode(String src,
int options)
IDNA2003: This function implements the ToUnicode operation as defined in the IDNA RFC. |
static StringBuffer |
convertToUnicode(UCharacterIterator src,
int options)
IDNA2003: Function that implements the ToUnicode operation as defined in the IDNA RFC. |
static IDNA |
getUTS46Instance(int options)
Returns an IDNA instance which implements UTS #46. |
protected static boolean |
hasCertainErrors(IDNA.Info info,
EnumSet<IDNA.Error> errors)
Deprecated. This API is ICU internal only. |
protected static boolean |
hasCertainLabelErrors(IDNA.Info info,
EnumSet<IDNA.Error> errors)
Deprecated. This API is ICU internal only. |
protected static boolean |
isBiDi(IDNA.Info info)
Deprecated. This API is ICU internal only. |
protected static boolean |
isOkBiDi(IDNA.Info info)
Deprecated. This API is ICU internal only. |
abstract StringBuilder |
labelToASCII(CharSequence label,
StringBuilder dest,
IDNA.Info info)
Converts a single domain name label into its ASCII form for DNS lookup. |
abstract StringBuilder |
labelToUnicode(CharSequence label,
StringBuilder dest,
IDNA.Info info)
Converts a single domain name label into its Unicode form for human-readable display. |
abstract StringBuilder |
nameToASCII(CharSequence name,
StringBuilder dest,
IDNA.Info info)
Converts a whole domain name into its ASCII form for DNS lookup. |
abstract StringBuilder |
nameToUnicode(CharSequence name,
StringBuilder dest,
IDNA.Info info)
Converts a whole domain name into its Unicode form for human-readable display. |
protected static void |
promoteAndResetLabelErrors(IDNA.Info info)
Deprecated. This API is ICU internal only. |
protected static void |
resetInfo(IDNA.Info info)
Deprecated. This API is ICU internal only. |
protected static void |
setBiDi(IDNA.Info info)
Deprecated. This API is ICU internal only. |
protected static void |
setNotOkBiDi(IDNA.Info info)
Deprecated. This API is ICU internal only. |
protected static void |
setTransitionalDifferent(IDNA.Info info)
Deprecated. This API is ICU internal only. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT
public static final int ALLOW_UNASSIGNED
public static final int USE_STD3_RULES
public static final int CHECK_BIDI
public static final int CHECK_CONTEXTJ
public static final int NONTRANSITIONAL_TO_ASCII
public static final int NONTRANSITIONAL_TO_UNICODE
Constructor Detail |
---|
protected IDNA()
Method Detail |
---|
public static IDNA getUTS46Instance(int options)
UTS #46 defines Unicode IDNA Compatibility Processing, updated to the latest version of Unicode and compatible with both IDNA2003 and IDNA2008.
The worker functions use transitional processing, including deviation mappings, unless NONTRANSITIONAL_TO_ASCII or NONTRANSITIONAL_TO_UNICODE is used in which case the deviation characters are passed through without change.
Disallowed characters are mapped to U+FFFD.
Operations with the UTS #46 instance do not support the ALLOW_UNASSIGNED option.
By default, the UTS #46 implementation allows all ASCII characters (as valid or mapped). When the USE_STD3_RULES option is used, ASCII characters other than letters, digits, hyphen (LDH) and dot/full stop are disallowed and mapped to U+FFFD.
options
- Bit set to modify the processing and error checking.
public abstract StringBuilder labelToASCII(CharSequence label, StringBuilder dest, IDNA.Info info)
label
- Input domain name labeldest
- Destination string objectinfo
- Output container of IDNA processing details.
public abstract StringBuilder labelToUnicode(CharSequence label, StringBuilder dest, IDNA.Info info)
label
- Input domain name labeldest
- Destination string objectinfo
- Output container of IDNA processing details.
public abstract StringBuilder nameToASCII(CharSequence name, StringBuilder dest, IDNA.Info info)
name
- Input domain namedest
- Destination string objectinfo
- Output container of IDNA processing details.
public abstract StringBuilder nameToUnicode(CharSequence name, StringBuilder dest, IDNA.Info info)
name
- Input domain namedest
- Destination string objectinfo
- Output container of IDNA processing details.
protected static void resetInfo(IDNA.Info info)
protected static boolean hasCertainErrors(IDNA.Info info, EnumSet<IDNA.Error> errors)
protected static boolean hasCertainLabelErrors(IDNA.Info info, EnumSet<IDNA.Error> errors)
protected static void addLabelError(IDNA.Info info, IDNA.Error error)
protected static void promoteAndResetLabelErrors(IDNA.Info info)
protected static void addError(IDNA.Info info, IDNA.Error error)
protected static void setTransitionalDifferent(IDNA.Info info)
protected static void setBiDi(IDNA.Info info)
protected static boolean isBiDi(IDNA.Info info)
protected static void setNotOkBiDi(IDNA.Info info)
protected static boolean isOkBiDi(IDNA.Info info)
public static StringBuffer convertToASCII(String src, int options) throws StringPrepParseException
src
- The input string to be processedoptions
- A bit set of options:
- IDNA.DEFAULT Use default options, i.e., do not process unassigned code points
and do not use STD3 ASCII rules
If unassigned code points are found the operation fails with
StringPrepParseException.
- IDNA.ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations
If this option is set, the unassigned code points are in the input
are treated as normal Unicode code points.
- IDNA.USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions
If this option is set and the input does not satisfy STD3 rules,
the operation will fail with ParseException
StringPrepParseException
- When an error occurs for parsing a string.public static StringBuffer convertToASCII(StringBuffer src, int options) throws StringPrepParseException
src
- The input string as StringBuffer to be processedoptions
- A bit set of options:
- IDNA.DEFAULT Use default options, i.e., do not process unassigned code points
and do not use STD3 ASCII rules
If unassigned code points are found the operation fails with
ParseException.
- IDNA.ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations
If this option is set, the unassigned code points are in the input
are treated as normal Unicode code points.
- IDNA.USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions
If this option is set and the input does not satisfy STD3 rules,
the operation will fail with ParseException
StringPrepParseException
public static StringBuffer convertToASCII(UCharacterIterator src, int options) throws StringPrepParseException
src
- The input string as UCharacterIterator to be processedoptions
- A bit set of options:
- IDNA.DEFAULT Use default options, i.e., do not process unassigned code points
and do not use STD3 ASCII rules
If unassigned code points are found the operation fails with
ParseException.
- IDNA.ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations
If this option is set, the unassigned code points are in the input
are treated as normal Unicode code points.
- IDNA.USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions
If this option is set and the input does not satisfy STD3 rules,
the operation will fail with ParseException
StringPrepParseException
public static StringBuffer convertIDNToASCII(UCharacterIterator src, int options) throws StringPrepParseException
src
- The input string as UCharacterIterator to be processedoptions
- A bit set of options:
- IDNA.DEFAULT Use default options, i.e., do not process unassigned code points
and do not use STD3 ASCII rules
If unassigned code points are found the operation fails with
ParseException.
- IDNA.ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations
If this option is set, the unassigned code points are in the input
are treated as normal Unicode code points.
- IDNA.USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions
If this option is set and the input does not satisfy STD3 rules,
the operation will fail with ParseException
StringPrepParseException
public static StringBuffer convertIDNToASCII(StringBuffer src, int options) throws StringPrepParseException
src
- The input string as a StringBuffer to be processedoptions
- A bit set of options:
- IDNA.DEFAULT Use default options, i.e., do not process unassigned code points
and do not use STD3 ASCII rules
If unassigned code points are found the operation fails with
ParseException.
- IDNA.ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations
If this option is set, the unassigned code points are in the input
are treated as normal Unicode code points.
- IDNA.USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions
If this option is set and the input does not satisfy STD3 rules,
the operation will fail with ParseException
StringPrepParseException
public static StringBuffer convertIDNToASCII(String src, int options) throws StringPrepParseException
src
- The input string to be processedoptions
- A bit set of options:
- IDNA.DEFAULT Use default options, i.e., do not process unassigned code points
and do not use STD3 ASCII rules
If unassigned code points are found the operation fails with
ParseException.
- IDNA.ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations
If this option is set, the unassigned code points are in the input
are treated as normal Unicode code points.
- IDNA.USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions
If this option is set and the input does not satisfy STD3 rules,
the operation will fail with ParseException
StringPrepParseException
public static StringBuffer convertToUnicode(String src, int options) throws StringPrepParseException
src
- The input string to be processedoptions
- A bit set of options:
- IDNA.DEFAULT Use default options, i.e., do not process unassigned code points
and do not use STD3 ASCII rules
If unassigned code points are found the operation fails with
ParseException.
- IDNA.ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations
If this option is set, the unassigned code points are in the input
are treated as normal Unicode code points.
- IDNA.USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions
If this option is set and the input does not satisfy STD3 rules,
the operation will fail with ParseException
StringPrepParseException
public static StringBuffer convertToUnicode(StringBuffer src, int options) throws StringPrepParseException
src
- The input string as StringBuffer to be processedoptions
- A bit set of options:
- IDNA.DEFAULT Use default options, i.e., do not process unassigned code points
and do not use STD3 ASCII rules
If unassigned code points are found the operation fails with
ParseException.
- IDNA.ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations
If this option is set, the unassigned code points are in the input
are treated as normal Unicode code points.
- IDNA.USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions
If this option is set and the input does not satisfy STD3 rules,
the operation will fail with ParseException
StringPrepParseException
public static StringBuffer convertToUnicode(UCharacterIterator src, int options) throws StringPrepParseException
src
- The input string as UCharacterIterator to be processedoptions
- A bit set of options:
- IDNA.DEFAULT Use default options, i.e., do not process unassigned code points
and do not use STD3 ASCII rules
If unassigned code points are found the operation fails with
ParseException.
- IDNA.ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations
If this option is set, the unassigned code points are in the input
are treated as normal Unicode code points.
- IDNA.USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions
If this option is set and the input does not satisfy STD3 rules,
the operation will fail with ParseException
StringPrepParseException
public static StringBuffer convertIDNToUnicode(UCharacterIterator src, int options) throws StringPrepParseException
src
- The input string as UCharacterIterator to be processedoptions
- A bit set of options:
- IDNA.DEFAULT Use default options, i.e., do not process unassigned code points
and do not use STD3 ASCII rules
If unassigned code points are found the operation fails with
ParseException.
- IDNA.ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations
If this option is set, the unassigned code points are in the input
are treated as normal Unicode code points.
- IDNA.USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions
If this option is set and the input does not satisfy STD3 rules,
the operation will fail with ParseException
StringPrepParseException
public static StringBuffer convertIDNToUnicode(StringBuffer src, int options) throws StringPrepParseException
src
- The input string as StringBuffer to be processedoptions
- A bit set of options:
- IDNA.DEFAULT Use default options, i.e., do not process unassigned code points
and do not use STD3 ASCII rules
If unassigned code points are found the operation fails with
ParseException.
- IDNA.ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations
If this option is set, the unassigned code points are in the input
are treated as normal Unicode code points.
- IDNA.USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions
If this option is set and the input does not satisfy STD3 rules,
the operation will fail with ParseException
StringPrepParseException
public static StringBuffer convertIDNToUnicode(String src, int options) throws StringPrepParseException
src
- The input string to be processedoptions
- A bit set of options:
- IDNA.DEFAULT Use default options, i.e., do not process unassigned code points
and do not use STD3 ASCII rules
If unassigned code points are found the operation fails with
ParseException.
- IDNA.ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations
If this option is set, the unassigned code points are in the input
are treated as normal Unicode code points.
- IDNA.USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions
If this option is set and the input does not satisfy STD3 rules,
the operation will fail with ParseException
StringPrepParseException
public static int compare(StringBuffer s1, StringBuffer s2, int options) throws StringPrepParseException
s1
- First IDN string as StringBuffers2
- Second IDN string as StringBufferoptions
- A bit set of options:
- IDNA.DEFAULT Use default options, i.e., do not process unassigned code points
and do not use STD3 ASCII rules
If unassigned code points are found the operation fails with
ParseException.
- IDNA.ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations
If this option is set, the unassigned code points are in the input
are treated as normal Unicode code points.
- IDNA.USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions
If this option is set and the input does not satisfy STD3 rules,
the operation will fail with ParseException
StringPrepParseException
public static int compare(String s1, String s2, int options) throws StringPrepParseException
s1
- First IDN strings2
- Second IDN stringoptions
- A bit set of options:
- IDNA.DEFAULT Use default options, i.e., do not process unassigned code points
and do not use STD3 ASCII rules
If unassigned code points are found the operation fails with
ParseException.
- IDNA.ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations
If this option is set, the unassigned code points are in the input
are treated as normal Unicode code points.
- IDNA.USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions
If this option is set and the input does not satisfy STD3 rules,
the operation will fail with ParseException
StringPrepParseException
public static int compare(UCharacterIterator s1, UCharacterIterator s2, int options) throws StringPrepParseException
s1
- First IDN string as UCharacterIterators2
- Second IDN string as UCharacterIteratoroptions
- A bit set of options:
- IDNA.DEFAULT Use default options, i.e., do not process unassigned code points
and do not use STD3 ASCII rules
If unassigned code points are found the operation fails with
ParseException.
- IDNA.ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations
If this option is set, the unassigned code points are in the input
are treated as normal Unicode code points.
- IDNA.USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions
If this option is set and the input does not satisfy STD3 rules,
the operation will fail with ParseException
StringPrepParseException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |