/** * Converts the specified character (Unicode code point) to its * UTF-16 representation stored in a {@code char} array. If * the specified code point is a BMP (Basic Multilingual Plane or * Plane 0) value, the resulting {@code char} array has * the same value as {@code codePoint}. If the specified code * point is a supplementary code point, the resulting * {@code char} array has the corresponding surrogate pair. * * @param codePoint a Unicode code point * @return a {@code char} array having * {@code codePoint}'s UTF-16 representation. * @exception IllegalArgumentException if the specified * {@code codePoint} is not a valid Unicode code point. * @since 1.5 */ public static char[] toChars(int codePoint) { if (isBmpCodePoint(codePoint)) { return new char[] { (char) codePoint }; } else if (isValidCodePoint(codePoint)) { char[] result = new char[2]; toSurrogates(codePoint, result, 0); return result; } else { throw new IllegalArgumentException(); } }
/** * Converts the specified character (Unicode code point) to its * UTF-16 representation stored in a {@code char} array. If * the specified code point is a BMP (Basic Multilingual Plane or * Plane 0) value, the resulting {@code char} array has * the same value as {@code codePoint}. If the specified code * point is a supplementary code point, the resulting * {@code char} array has the corresponding surrogate pair. * * @param codePoint a Unicode code point * @return a {@code char} array having * {@code codePoint}'s UTF-16 representation. * @exception IllegalArgumentException if the specified * {@code codePoint} is not a valid Unicode code point. * @since 1.5 */ public static char[] toChars(int codePoint) { if (isBmpCodePoint(codePoint)) { return new char[] { (char) codePoint }; } else if (isValidCodePoint(codePoint)) { char[] result = new char[2]; toSurrogates(codePoint, result, 0); return result; } else { throw new IllegalArgumentException(); } }
return 1; } else if (isValidCodePoint(codePoint)) { toSurrogates(codePoint, dst, dstIndex); return 2; } else {
return 1; } else if (isValidCodePoint(codePoint)) { toSurrogates(codePoint, dst, dstIndex); return 2; } else {
} else if (Character.isValidCodePoint(codePoint)) { ensureCapacityInternal(count + 2); Character.toSurrogates(codePoint, value, count); this.count = count + 2; } else {
} else if (Character.isValidCodePoint(codePoint)) { ensureCapacityInternal(count + 2); Character.toSurrogates(codePoint, value, count); this.count = count + 2; } else {
v[j] = (char) c; else Character.toSurrogates(c, v, j++);
v[j] = (char) c; else Character.toSurrogates(c, v, j++);