From 18638d30c059ca0f2e23674ba9ef68296f44c6bd Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Fri, 10 Jan 2014 20:33:31 +0900 Subject: [PATCH] [IL71] Add indices to toCodePointArray. This is necessary for tests Bug: 8636060 Change-Id: I50ea401a22e4df72333eda61ca39aa180966ee4b --- .../android/inputmethod/latin/utils/StringUtils.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/utils/StringUtils.java b/java/src/com/android/inputmethod/latin/utils/StringUtils.java index 5920c68f1..8fc245d9b 100644 --- a/java/src/com/android/inputmethod/latin/utils/StringUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/StringUtils.java @@ -171,13 +171,19 @@ public final class StringUtils { private static final int[] EMPTY_CODEPOINTS = {}; public static int[] toCodePointArray(final String string) { + return toCodePointArray(string, 0, string.length()); + } + + public static int[] toCodePointArray(final String string, + final int startIndex, final int endIndex) { final int length = string.length(); if (length <= 0) { return EMPTY_CODEPOINTS; } - final int[] codePoints = new int[string.codePointCount(0, length)]; + final int[] codePoints = new int[string.codePointCount(startIndex, endIndex)]; int destIndex = 0; - for (int index = 0; index < length; index = string.offsetByCodePoints(index, 1)) { + for (int index = startIndex; index < endIndex; + index = string.offsetByCodePoints(index, 1)) { codePoints[destIndex] = string.codePointAt(index); destIndex++; }