private static int[] toCodePoints(char[] str) { int[] codePoints = new int[Character.codePointCount(str, 0, str.length)]; for (int i = 0, c = 0; i < str.length; c++) { int cp = Character.codePointAt(str, i); codePoints[c] = cp; i += Character.charCount(cp); } return codePoints; }
/** Calculates the number of Unicode code points between {@code beginIndex} and {@code endIndex}. * * @param beginIndex the inclusive beginning index of the subsequence. * @param endIndex the exclusive end index of the subsequence. * @return the number of Unicode code points in the subsequence. * @throws IndexOutOfBoundsException if {@code beginIndex} is negative or greater than {@code endIndex} or {@code endIndex} is * greater than {@link #length()}. * @see Character * @see Character#codePointCount(char[], int, int) * @since 1.5 */ public int codePointCount (int beginIndex, int endIndex) { if (beginIndex < 0 || endIndex > length || beginIndex > endIndex) { throw new StringIndexOutOfBoundsException(); } return Character.codePointCount(chars, beginIndex, endIndex - beginIndex); }
/** Calculates the number of Unicode code points between {@code beginIndex} and {@code endIndex}. * * @param beginIndex the inclusive beginning index of the subsequence. * @param endIndex the exclusive end index of the subsequence. * @return the number of Unicode code points in the subsequence. * @throws IndexOutOfBoundsException if {@code beginIndex} is negative or greater than {@code endIndex} or {@code endIndex} is * greater than {@link #length()}. * @see Character * @see Character#codePointCount(char[], int, int) * @since 1.5 */ public int codePointCount (int beginIndex, int endIndex) { if (beginIndex < 0 || endIndex > length || beginIndex > endIndex) { throw new StringIndexOutOfBoundsException(); } return Character.codePointCount(chars, beginIndex, endIndex - beginIndex); }
@Override public int translate(final CharSequence input, final int index, final Writer out) throws IOException { if(index != 0) { throw new IllegalStateException("CsvEscaper should never reach the [1] index"); } if (StringUtils.containsNone(input.toString(), CSV_SEARCH_CHARS)) { out.write(input.toString()); } else { out.write(CSV_QUOTE); out.write(StringUtils.replace(input.toString(), CSV_QUOTE_STR, CSV_QUOTE_STR + CSV_QUOTE_STR)); out.write(CSV_QUOTE); } return Character.codePointCount(input, 0, input.length()); } }
private static int[] toCodePoints(char[] str) { int[] codePoints = new int[Character.codePointCount(str, 0, str.length)]; for (int i = 0, c = 0; i < str.length; c++) { int cp = Character.codePointAt(str, i); codePoints[c] = cp; i += Character.charCount(cp); } return codePoints; }
@Override public int translate(final CharSequence input, final int index, final Writer out) throws IOException { if(index != 0) { throw new IllegalStateException("CsvUnescaper should never reach the [1] index"); } if ( input.charAt(0) != CSV_QUOTE || input.charAt(input.length() - 1) != CSV_QUOTE ) { out.write(input.toString()); return Character.codePointCount(input, 0, input.length()); } // strip quotes final String quoteless = input.subSequence(1, input.length() - 1).toString(); if ( StringUtils.containsAny(quoteless, CSV_SEARCH_CHARS) ) { // deal with escaped quotes; ie) "" out.write(StringUtils.replace(quoteless, CSV_QUOTE_STR + CSV_QUOTE_STR, CSV_QUOTE_STR)); } else { out.write(input.toString()); } return Character.codePointCount(input, 0, input.length()); } }
private static int[] codePoints(String input) { int length = Character.codePointCount(input, 0, input.length()); int word[] = new int[length]; for (int i = 0, j = 0, cp = 0; i < input.length(); i += Character.charCount(cp)) { word[j++] = cp = input.codePointAt(i); } return word; }
/** * Calculates the number of Unicode code points between {@code start} * and {@code end}. * * @param start * the inclusive beginning index of the subsequence. * @param end * the exclusive end index of the subsequence. * @return the number of Unicode code points in the subsequence. * @throws IndexOutOfBoundsException * if {@code start < 0 || end > length() || start > end} * @see Character#codePointCount(CharSequence, int, int) * @since 1.5 */ public int codePointCount(int start, int end) { if (start < 0 || end > count || start > end) { throw startEndAndLength(start, end); } return Character.codePointCount(value, offset + start, end - start); }
/** * Calculates the number of Unicode code points between {@code start} * and {@code end}. * * @param start * the inclusive beginning index of the subsequence. * @param end * the exclusive end index of the subsequence. * @return the number of Unicode code points in the subsequence. * @throws IndexOutOfBoundsException * if {@code start} is negative or greater than * {@code end} or {@code end} is greater than * {@link #length()}. * @see Character * @see Character#codePointCount(char[], int, int) * @since 1.5 */ public int codePointCount(int start, int end) { if (start < 0 || end > count || start > end) { throw startEndAndLength(start, end); } return Character.codePointCount(value, start, end - start); }
/** * @param text string where to search * @return true if each character in pattern is found sequentially within text */ public MatchInfo match(CharSequence text) { int idx = 0; int idxCodepoint = 0; int textLength = text.length(); int[] codepoints = new int[Character.codePointCount(text, 0, textLength)]; while (idx < textLength) { int codepoint = Character.codePointAt(text, idx); codepoints[idxCodepoint] = codepoint; idx += Character.charCount(codepoint); idxCodepoint += 1; } return match(codepoints); }
int length = Character.codePointCount(input, 0, input.length()); word = new int[length]; for (int i = 0, j = 0, cp = 0; i < input.length(); i += Character.charCount(cp)) {
public static StringNormalizer.Result simplifyPhoneNumber(String phoneNumber) { // This is done manually for performance reason, // But the algorithm is just a regexp replacement of "[-.():/ ]" with "" int numCodePoints = Character.codePointCount(phoneNumber, 0, phoneNumber.length()); IntSequenceBuilder codePoints = new IntSequenceBuilder(numCodePoints); IntSequenceBuilder resultMap = new IntSequenceBuilder(numCodePoints); int i = 0; for (int iterCodePoint = 0; iterCodePoint < numCodePoints; iterCodePoint += 1) { int c = Character.codePointAt(phoneNumber, i); if (c != ' ' && c != '-' && c != '.' && c != '(' && c != ')' && c != ':' && c != '/') { codePoints.add(c); resultMap.add(i); } i += Character.charCount(c); } return new StringNormalizer.Result(phoneNumber.length(), codePoints.toArray(), resultMap.toArray()); } }
@Override public boolean accept() { final int max32 = termAtt.length(); final int min32 = max32 >> 1; if (min32 >= min && max32 <= max) { // definitely within range return true; } else if (min32 > max || max32 < min) { // definitely not return false; } else { // we must count to be sure int len = Character.codePointCount(termAtt.buffer(), 0, termAtt.length()); return (len >= min && len <= max); } } }
int numCodePoints = Character.codePointCount(input, 0, input.length()); IntSequenceBuilder codePoints = new IntSequenceBuilder(numCodePoints); IntSequenceBuilder resultMap = new IntSequenceBuilder(numCodePoints);
boolean isHindi = false; for (int k = 0; k < Character.codePointCount(myString, 0, myString.length()); k++) { int c = myString.codePointAt(k); if (c >= 0x0900 && c <= 0x097F) { //Hindi uni-codes are within this range isHindi = true; break; } }
public static boolean textIsPersian(String s) { for (int i = 0; i < Character.codePointCount(s, 0, s.length()); i++) { int c = s.codePointAt(i); if (c >= 0x0600 && c <=0x06FF || c== 0xFB8A || c==0x067E || c==0x0686 || c==0x06AF) return true; } return false;
public static boolean textIsPersian(String s) { for (int i = 0; i < Character.codePointCount(s, 0, s.length()); i++) { int c = s.codePointAt(i); if ((c >= 0x0600 && c <=0x06FF) || (c>=0xFB50 && c<=0xFDFF) || (c>=0xFE70 && c<=0xFEFF) ) return true; } return false; }
curTermCodePointCount = Character.codePointCount(termAtt, 0, curTermLength); curPosIncr += posIncrAtt.getPositionIncrement();
private static int[] codePoints(String input) { int length = Character.codePointCount(input, 0, input.length()); int word[] = new int[length]; for (int i = 0, j = 0, cp = 0; i < input.length(); i += Character.charCount(cp)) { word[j++] = cp = input.codePointAt(i); } return word; }
curTermCodePointCount = Character.codePointCount(termAtt, 0, termAtt.length()); curPosIncr += posIncrAtt.getPositionIncrement(); curPos = 0;