diff options
author | 2013-12-16 14:17:50 +0000 | |
---|---|---|
committer | 2013-12-16 14:17:51 +0000 | |
commit | 0c7b05fc50edaae5c4e079410dfc7eb8cd14261c (patch) | |
tree | 97c9f008250b6e8a361e31c957df8b28c08e1db7 /java/src/com/android/inputmethod/latin/utils/StringUtils.java | |
parent | e17cc8270f280e998a7500abd375b8870e07af65 (diff) | |
parent | 7cd7cf73f4ce6f0e577d6382eb0fc25f60dc63e1 (diff) | |
download | latinime-0c7b05fc50edaae5c4e079410dfc7eb8cd14261c.tar.gz latinime-0c7b05fc50edaae5c4e079410dfc7eb8cd14261c.tar.xz latinime-0c7b05fc50edaae5c4e079410dfc7eb8cd14261c.zip |
Merge "Fix a bug with languages without spaces and predictions"
Diffstat (limited to 'java/src/com/android/inputmethod/latin/utils/StringUtils.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/utils/StringUtils.java | 18 |
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 df420417d..85f44541e 100644 --- a/java/src/com/android/inputmethod/latin/utils/StringUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/StringUtils.java @@ -250,6 +250,24 @@ public final class StringUtils { return true; } + /** + * Returns true if all code points in text are whitespace, false otherwise. Empty is true. + */ + // Interestingly enough, U+00A0 NO-BREAK SPACE and U+200B ZERO-WIDTH SPACE are not considered + // whitespace, while EN SPACE, EM SPACE and IDEOGRAPHIC SPACES are. + public static boolean containsOnlyWhitespace(final String text) { + final int length = text.length(); + int i = 0; + while (i < length) { + final int codePoint = text.codePointAt(i); + if (!Character.isWhitespace(codePoint)) { + return false; + } + i += Character.charCount(codePoint); + } + return true; + } + @UsedForTesting public static boolean looksValidForDictionaryInsertion(final CharSequence text, final SettingsValues settings) { |