diff options
author | 2012-11-06 12:49:53 +0900 | |
---|---|---|
committer | 2012-11-06 12:49:53 +0900 | |
commit | 555e15a96a00e8829981557d96e9fa7fc5a74f8c (patch) | |
tree | 9750c7af9777b63c176cc780c2a6de4849931434 /native/jni/src/char_utils.h | |
parent | 9381ab669f12664f7e2debea846d3ce71f89b256 (diff) | |
parent | 5f2fa6b82cbb6714ab2996aebc16f10c62d0e673 (diff) | |
download | latinime-555e15a96a00e8829981557d96e9fa7fc5a74f8c.tar.gz latinime-555e15a96a00e8829981557d96e9fa7fc5a74f8c.tar.xz latinime-555e15a96a00e8829981557d96e9fa7fc5a74f8c.zip |
Merge remote-tracking branch 'goog/master' into mergescriptpackage
Conflicts:
java/res/values-ca/strings.xml
java/res/values-cs/strings.xml
java/res/values-de/strings.xml
java/res/values-es/strings.xml
java/res/values-hr/strings.xml
java/res/values-hu/strings.xml
java/res/values-it/strings.xml
java/res/values-lv/strings.xml
java/res/values-nb/strings.xml
java/res/values-nl/strings.xml
java/res/values-pl/strings.xml
java/res/values-pt/strings.xml
java/res/values-ro/strings.xml
java/res/values-ru/strings.xml
java/res/values-sv/strings.xml
java/res/values-sw/strings.xml
java/res/values-tr/strings.xml
java/res/values-uk/strings.xml
java/res/values-zh-rCN/strings.xml
java/res/values-zh-rTW/strings.xml
java/src/com/android/inputmethod/latin/RichInputConnection.java
Change-Id: Iba00dd5b86cb16d72968bc7e40d75853845b6dcb
Diffstat (limited to 'native/jni/src/char_utils.h')
-rw-r--r-- | native/jni/src/char_utils.h | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/native/jni/src/char_utils.h b/native/jni/src/char_utils.h index b17f262ec..c632b79b8 100644 --- a/native/jni/src/char_utils.h +++ b/native/jni/src/char_utils.h @@ -18,20 +18,23 @@ #define LATINIME_CHAR_UTILS_H #include <cctype> -#include <stdint.h> + +#include "defines.h" namespace latinime { -inline static bool isAsciiUpper(unsigned short c) { - return isupper(static_cast<int>(c)) != 0; +inline static bool isAsciiUpper(int c) { + // Note: isupper(...) reports false positives for some Cyrillic characters, causing them to + // be incorrectly lower-cased using toAsciiLower(...) rather than latin_tolower(...). + return (c >= 'A' && c <= 'Z'); } -inline static unsigned short toAsciiLower(unsigned short c) { +inline static int toAsciiLower(int c) { return c - 'A' + 'a'; } -inline static bool isAscii(unsigned short c) { - return isascii(static_cast<int>(c)) != 0; +inline static bool isAscii(int c) { + return isascii(c) != 0; } unsigned short latin_tolower(const unsigned short c); @@ -42,28 +45,33 @@ unsigned short latin_tolower(const unsigned short c); * if c is not a combined character, or the base character if it * is combined. */ - static const int BASE_CHARS_SIZE = 0x0500; -extern const uint16_t BASE_CHARS[BASE_CHARS_SIZE]; +extern const unsigned short BASE_CHARS[BASE_CHARS_SIZE]; -inline static unsigned short toBaseChar(unsigned short c) { +inline static int toBaseCodePoint(int c) { if (c < BASE_CHARS_SIZE) { - return BASE_CHARS[c]; + return static_cast<int>(BASE_CHARS[c]); } return c; } -inline static unsigned short toLowerCase(const unsigned short c) { +AK_FORCE_INLINE static int toLowerCase(const int c) { if (isAsciiUpper(c)) { return toAsciiLower(c); } else if (isAscii(c)) { return c; } - return latin_tolower(c); + return static_cast<int>(latin_tolower(static_cast<unsigned short>(c))); } -inline static unsigned short toBaseLowerCase(const unsigned short c) { - return toLowerCase(toBaseChar(c)); +AK_FORCE_INLINE static int toBaseLowerCase(const int c) { + return toLowerCase(toBaseCodePoint(c)); } + +inline static bool isSkippableCodePoint(const int codePoint) { + // TODO: Do not hardcode here + return codePoint == KEYCODE_SINGLE_QUOTE || codePoint == KEYCODE_HYPHEN_MINUS; +} + } // namespace latinime #endif // LATINIME_CHAR_UTILS_H |