/** * Gets the current string from the iterator. Only use after calling next(), not nextRange(). * @stable ICU 4.0 */ public String getString() { if (codepoint != IS_STRING) { return UTF16.valueOf(codepoint); } return string; }
/** * Convenience method that can have faster implementation * by not allocating buffers. * @param char32a the first code point to be checked against the * @param char32b the second code point * @param options A bit set of options * @stable ICU 2.8 */ public static int compare(int char32a, int char32b, int options) { return internalCompare(UTF16.valueOf(char32a), UTF16.valueOf(char32b), options|INPUT_IS_FCD); }
/** * Convenience method that can have faster implementation * by not allocating buffers. * @param char32a the first code point to be checked against * @param str2 the second string * @param options A bit set of options * @stable ICU 2.8 */ public static int compare(int char32a, String str2, int options) { return internalCompare(UTF16.valueOf(char32a), str2, options); }
/** * Convenience Method * @param char32 the input code point to be checked to see if it is * normalized * @param mode the normalization mode * @param options Options for use with exclusion set and tailored Normalization * The only option that is currently recognized is UNICODE_3_2 * * @see #isNormalized * @deprecated ICU 56 Use {@link Normalizer2} instead. */ @Deprecated public static boolean isNormalized(int char32, Mode mode,int options) { return isNormalized(UTF16.valueOf(char32), mode, options); }
/** * Transliterates the portion of the text buffer that can be * transliterated unambiguosly after a new character has been * inserted, typically as a result of a keyboard event. This is a * convenience method; see {@link #transliterate(Replaceable, * Transliterator.Position, String)} for details. * @param text the buffer holding transliterated and * untransliterated text * @param index the start and limit of the text, the position * of the cursor, and the start and limit of transliteration. * @param insertion text to be inserted and possibly * transliterated into the translation buffer at * <code>index.contextLimit</code>. * @see #transliterate(Replaceable, Transliterator.Position, String) * @stable ICU 2.0 */ public final void transliterate(Replaceable text, Position index, int insertion) { transliterate(text, index, UTF16.valueOf(insertion)); }
/** * Inserts char32 codepoint into target at the argument offset16. If the offset16 is in the * middle of a supplementary codepoint, char32 will be inserted after the supplementary * codepoint. The length of target increases by one if codepoint is non-supplementary, 2 * otherwise. * <p> * The overall effect is exactly as if the argument were converted to a string by the method * valueOf(char) and the characters in that string were then inserted into target at the * position indicated by offset16. * </p> * <p> * The offset argument must be greater than or equal to 0, and less than or equal to the length * of source. * * @param target String buffer to insert to * @param offset16 Offset which char32 will be inserted in * @param char32 Codepoint to be inserted * @return a reference to target * @exception IndexOutOfBoundsException Thrown if offset16 is invalid. * @stable ICU 2.1 */ public static StringBuffer insert(StringBuffer target, int offset16, int char32) { String str = valueOf(char32); if (offset16 != target.length() && bounds(target, offset16) == TRAIL_SURROGATE_BOUNDARY) { offset16++; } target.insert(offset16, str); return target; }
/** * Normalize a codepoint according to the given mode * @param char32 The input string to be normalized. * @param mode The normalization mode * @param options Options for use with exclusion set and tailored Normalization * The only option that is currently recognized is UNICODE_3_2 * @return String The normalized string * @see #UNICODE_3_2 * @deprecated ICU 56 Use {@link Normalizer2} instead. */ @Deprecated public static String normalize(int char32, Mode mode, int options) { if(mode == NFD && options == 0) { String decomposition = Normalizer2.getNFCInstance().getDecomposition(char32); if(decomposition == null) { decomposition = UTF16.valueOf(char32); } return decomposition; } return normalize(UTF16.valueOf(char32), mode, options); }
String str = valueOf(char32); if (offset16 != limit && bounds(target, 0, limit, offset16) == TRAIL_SURROGATE_BOUNDARY) { offset16++;
@Override boolean contains(int c) { Normalizer2Impl kcf=Norm2AllModes.getNFKC_CFInstance().impl; String src=UTF16.valueOf(c); StringBuilder dest=new StringBuilder(); // Small destCapacity for NFKC_CF(c). Normalizer2Impl.ReorderingBuffer buffer=new Normalizer2Impl.ReorderingBuffer(kcf, dest, 5); kcf.compose(src, 0, src.length(), false, true, buffer); return !Normalizer2Impl.UTF16Plus.equal(dest, src); } },
/** * Set a code point into a UTF16 position. Adjusts target according if we are replacing a * non-supplementary codepoint with a supplementary and vice versa. * * @param target Stringbuffer * @param offset16 UTF16 position to insert into * @param char32 Code point * @stable ICU 2.1 */ public static void setCharAt(StringBuffer target, int offset16, int char32) { int count = 1; char single = target.charAt(offset16); if (isSurrogate(single)) { // pairs of the surrogate with offset16 at the lead char found if (isLeadSurrogate(single) && (target.length() > offset16 + 1) && isTrailSurrogate(target.charAt(offset16 + 1))) { count++; } else { // pairs of the surrogate with offset16 at the trail char // found if (isTrailSurrogate(single) && (offset16 > 0) && isLeadSurrogate(target.charAt(offset16 - 1))) { offset16--; count++; } } } target.replace(offset16, offset16 + count, valueOf(char32)); }
return buffer.toString(); } else if(isDecompNoAlgorithmic(norm16)) { return UTF16.valueOf(mapAlgorithmic(c, norm16)); } else {
String chStr = UTF16.valueOf(source, i); for (String s : subpermute) { String piece = chStr + s;
if (PROGRESS) System.out.println(" extract: " + Utility.hex(UTF16.valueOf(comp)) + ", " + Utility.hex(segment.substring(segmentPos))); decomp = UTF16.valueOf(comp); cp = UTF16.charAt(segment, i); if (cp == decompCp) { // if equal, eat another cp from decomp if (PROGRESS) System.out.println(" matches: " + Utility.hex(UTF16.valueOf(cp))); if (decompPos == decomp.length()) { // done, have all decomp characters! if (PROGRESS) System.out.println(" buffer: " + Utility.hex(UTF16.valueOf(cp))); if (0!=Normalizer.compare(UTF16.valueOf(comp) + remainder, segment.substring(segmentPos), 0)) return null;
prefix += UTF16.valueOf(cp2); for (String item : remainder) { result.add(prefix + item);
String str = valueOf(char32); int result = limit; int strlength = str.length();
return null; } else { return UTF16.valueOf(decomp);
} else { delta=iter.replace(UTF16.valueOf(c));
} else { delta=iter.replace(UTF16.valueOf(c));
} else { delta=iter.replace(UTF16.valueOf(c));