public static String toUnicode(String s, int flags) { try { return convert(s, flags, false); } catch (IllegalArgumentException ex) { // The RI documentation explicitly states that this method can't fail. // ICU4C disagrees, as does the RI in practice. // The RI just returns the input string if it can't return s; } }
private static String convert(String s, int flags, boolean toAscii) { if (s == null) { throw new NullPointerException("s == null"); } return convertImpl(s, flags, toAscii); } private static native String convertImpl(String s, int flags, boolean toAscii);
/** * Transform a Unicode String to ASCII Compatible Encoding String according * to the algorithm defined in <a href="http://www.ietf.org/rfc/rfc3490.txt">RFC 3490</a>. * * <p>If the transformation fails (because the input is not a valid IDN), an * exception will be thrown. * * <p>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. * * @param input the Unicode name * @param flags 0, {@code ALLOW_UNASSIGNED}, {@code USE_STD3_ASCII_RULES}, * or {@code ALLOW_UNASSIGNED | USE_STD3_ASCII_RULES} * @return the ACE name * @throws IllegalArgumentException if {@code input} does not conform to <a href="http://www.ietf.org/rfc/rfc3490.txt">RFC 3490</a> */ public static String toASCII(String input, int flags) { return NativeIDN.toASCII(input, flags); }
/** * Equivalent to {@code toUnicode(input, 0)}. * * @param input the ACE name * @return the Unicode name */ public static String toUnicode(String input) { return NativeIDN.toUnicode(input, 0); } }
/** * Translates a string from ASCII Compatible Encoding (ACE) to Unicode * according to the algorithm defined in <a href="http://www.ietf.org/rfc/rfc3490.txt">RFC 3490</a>. * * <p>Unlike {@code toASCII}, this transformation cannot fail. * * <p>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). * * @param input the ACE name * @return the Unicode name * @param flags 0, {@code ALLOW_UNASSIGNED}, {@code USE_STD3_ASCII_RULES}, * or {@code ALLOW_UNASSIGNED | USE_STD3_ASCII_RULES} */ public static String toUnicode(String input, int flags) { return NativeIDN.toUnicode(input, flags); }
public static String toASCII(String s, int flags) { return convert(s, flags, true); }
/** * Equivalent to {@code toUnicode(input, 0)}. * * @param input the ACE name * @return the Unicode name */ public static String toUnicode(String input) { return NativeIDN.toUnicode(input, 0); } }
private static String convert(String s, int flags, boolean toAscii) { if (s == null) { throw new NullPointerException("s == null"); } return convertImpl(s, flags, toAscii); } private static native String convertImpl(String s, int flags, boolean toAscii);
/** * Transform a Unicode String to ASCII Compatible Encoding String according * to the algorithm defined in <a href="http://www.ietf.org/rfc/rfc3490.txt">RFC 3490</a>. * * <p>If the transformation fails (because the input is not a valid IDN), an * exception will be thrown. * * <p>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. * * @param input the Unicode name * @param flags 0, {@code ALLOW_UNASSIGNED}, {@code USE_STD3_ASCII_RULES}, * or {@code ALLOW_UNASSIGNED | USE_STD3_ASCII_RULES} * @return the ACE name * @throws IllegalArgumentException if {@code input} does not conform to <a href="http://www.ietf.org/rfc/rfc3490.txt">RFC 3490</a> */ public static String toASCII(String input, int flags) { return NativeIDN.toASCII(input, flags); }
public static String toUnicode(String s, int flags) { try { return convert(s, flags, false); } catch (IllegalArgumentException ex) { // The RI documentation explicitly states that this method can't fail. // ICU4C disagrees, as does the RI in practice. // The RI just returns the input string if it can't return s; } }
/** * Equivalent to {@code toUnicode(input, 0)}. * * @param input the ACE name * @return the Unicode name */ public static String toUnicode(String input) { return NativeIDN.toUnicode(input, 0); } }
private static String convert(String s, int flags, boolean toAscii) { if (s == null) { throw new NullPointerException("s == null"); } return convertImpl(s, flags, toAscii); } private static native String convertImpl(String s, int flags, boolean toAscii);
/** * Transform a Unicode String to ASCII Compatible Encoding String according * to the algorithm defined in <a href="http://www.ietf.org/rfc/rfc3490.txt">RFC 3490</a>. * * <p>If the transformation fails (because the input is not a valid IDN), an * exception will be thrown. * * <p>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. * * @param input the Unicode name * @param flags 0, {@code ALLOW_UNASSIGNED}, {@code USE_STD3_ASCII_RULES}, * or {@code ALLOW_UNASSIGNED | USE_STD3_ASCII_RULES} * @return the ACE name * @throws IllegalArgumentException if {@code input} does not conform to <a href="http://www.ietf.org/rfc/rfc3490.txt">RFC 3490</a> */ public static String toASCII(String input, int flags) { return NativeIDN.toASCII(input, flags); }
public static String toUnicode(String s, int flags) { try { return convert(s, flags, false); } catch (IllegalArgumentException ex) { // The RI documentation explicitly states that this method can't fail. // ICU4C disagrees, as does the RI in practice. // The RI just returns the input string if it can't return s; } }
/** * Equivalent to {@code toUnicode(input, 0)}. * * @param input the ACE name * @return the Unicode name */ public static String toUnicode(String input) { return NativeIDN.toUnicode(input, 0); } }
private static String convert(String s, int flags, boolean toAscii) { if (s == null) { throw new NullPointerException("s == null"); } return convertImpl(s, flags, toAscii); } private static native String convertImpl(String s, int flags, boolean toAscii);
/** * Transform a Unicode String to ASCII Compatible Encoding String according * to the algorithm defined in <a href="http://www.ietf.org/rfc/rfc3490.txt">RFC 3490</a>. * * <p>If the transformation fails (because the input is not a valid IDN), an * exception will be thrown. * * <p>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. * * @param input the Unicode name * @param flags 0, {@code ALLOW_UNASSIGNED}, {@code USE_STD3_ASCII_RULES}, * or {@code ALLOW_UNASSIGNED | USE_STD3_ASCII_RULES} * @return the ACE name * @throws IllegalArgumentException if {@code input} does not conform to <a href="http://www.ietf.org/rfc/rfc3490.txt">RFC 3490</a> */ public static String toASCII(String input, int flags) { return NativeIDN.toASCII(input, flags); }
public static String toASCII(String s, int flags) { return convert(s, flags, true); }
/** * Equivalent to {@code toUnicode(input, 0)}. * * @param input the ACE name * @return the Unicode name */ public static String toUnicode(String input) { return NativeIDN.toUnicode(input, 0); } }
private static String convert(String s, int flags, boolean toAscii) { if (s == null) { throw new NullPointerException("s == null"); } return convertImpl(s, flags, toAscii); } private static native String convertImpl(String s, int flags, boolean toAscii);