aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/StringUtils.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2013-04-09 23:33:43 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-04-09 23:33:43 -0700
commitf5aa2fd5c868cae6e879858738a5eef4445aaca8 (patch)
treef77be0fd676cf5fb7bb4b38e82415fefc214fa3a /java/src/com/android/inputmethod/latin/StringUtils.java
parente81c16788712590fd6cf9e14420d50acf029ad48 (diff)
parent10af4b6e45689cba9bdc8c22f1bb76bf8bd2516b (diff)
downloadlatinime-f5aa2fd5c868cae6e879858738a5eef4445aaca8.tar.gz
latinime-f5aa2fd5c868cae6e879858738a5eef4445aaca8.tar.xz
latinime-f5aa2fd5c868cae6e879858738a5eef4445aaca8.zip
am 10af4b6e: Merge "Separate StringUtils.capitalizeFirstCharacter"
* commit '10af4b6e45689cba9bdc8c22f1bb76bf8bd2516b': Separate StringUtils.capitalizeFirstCharacter
Diffstat (limited to 'java/src/com/android/inputmethod/latin/StringUtils.java')
-rw-r--r--java/src/com/android/inputmethod/latin/StringUtils.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/StringUtils.java b/java/src/com/android/inputmethod/latin/StringUtils.java
index 59ad28fc9..4de104af5 100644
--- a/java/src/com/android/inputmethod/latin/StringUtils.java
+++ b/java/src/com/android/inputmethod/latin/StringUtils.java
@@ -106,10 +106,18 @@ public final class StringUtils {
}
}
+ public static String capitalizeFirstCharacter(final String s, final Locale locale) {
+ if (s.length() <= 1) {
+ return s.toUpperCase(locale);
+ }
+ // Please refer to the comment below in {@link #toTitleCase(String,Locale)}.
+ final int cutoff = s.offsetByCodePoints(0, 1);
+ return s.substring(0, cutoff).toUpperCase(locale) + s.substring(cutoff);
+ }
+
public static String toTitleCase(final String s, final Locale locale) {
if (s.length() <= 1) {
- // TODO: is this really correct? Shouldn't this be s.toUpperCase()?
- return s;
+ return s.toUpperCase(locale);
}
// TODO: fix the bugs below
// - This does not work for Greek, because it returns upper case instead of title case.