aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/utils/StringUtils.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-01-31 14:20:15 +0900
committerTadashi G. Takaoka <takaoka@google.com>2014-01-31 14:49:36 +0900
commit639bf62e4fc12c4f75ed0491512f6ed9d2fc2432 (patch)
treee41744c069801a306a06aa637d6dc7454766e8d8 /java/src/com/android/inputmethod/latin/utils/StringUtils.java
parent776d46a771089482c68be56e81219bbd7bb559e4 (diff)
downloadlatinime-639bf62e4fc12c4f75ed0491512f6ed9d2fc2432.tar.gz
latinime-639bf62e4fc12c4f75ed0491512f6ed9d2fc2432.tar.xz
latinime-639bf62e4fc12c4f75ed0491512f6ed9d2fc2432.zip
Move some methods to StringUtils
Change-Id: I29d87fdd65ec879d1c0bdf7e7792a677687c1693
Diffstat (limited to 'java/src/com/android/inputmethod/latin/utils/StringUtils.java')
-rw-r--r--java/src/com/android/inputmethod/latin/utils/StringUtils.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/utils/StringUtils.java b/java/src/com/android/inputmethod/latin/utils/StringUtils.java
index b154623ae..c632a71a9 100644
--- a/java/src/com/android/inputmethod/latin/utils/StringUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/StringUtils.java
@@ -16,6 +16,8 @@
package com.android.inputmethod.latin.utils;
+import static com.android.inputmethod.latin.Constants.CODE_UNSPECIFIED;
+
import android.text.TextUtils;
import com.android.inputmethod.annotations.UsedForTesting;
@@ -471,4 +473,20 @@ public final class StringUtils {
}
return bytes;
}
+
+ public static String toUpperCaseOfStringForLocale(final String text,
+ final boolean needsToUpperCase, final Locale locale) {
+ if (text == null || !needsToUpperCase) return text;
+ return text.toUpperCase(locale);
+ }
+
+ public static int toUpperCaseOfCodeForLocale(final int code, final boolean needsToUpperCase,
+ final Locale locale) {
+ if (!Constants.isLetterCode(code) || !needsToUpperCase) return code;
+ final String text = newSingleCodePointString(code);
+ final String casedText = toUpperCaseOfStringForLocale(
+ text, needsToUpperCase, locale);
+ return codePointCount(casedText) == 1
+ ? casedText.codePointAt(0) : CODE_UNSPECIFIED;
+ }
}