aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2015-02-23 10:10:54 +1100
committerNeil <nyamatongwe@gmail.com>2015-02-23 10:10:54 +1100
commitc4c875b860d9a447967b625f67748e962b697652 (patch)
tree58c0712ac5b959bc7ad559a40c84e7eeb1155c64 /src
parentee3a66f0ebaea12c3fd4000a1acffdcc2b93176f (diff)
downloadscintilla-mirror-c4c875b860d9a447967b625f67748e962b697652.tar.gz
Fix non-BMP character entry through the inline IME.
Diffstat (limited to 'src')
-rw-r--r--src/UniConversion.cxx6
-rw-r--r--src/UniConversion.h6
2 files changed, 9 insertions, 3 deletions
diff --git a/src/UniConversion.cxx b/src/UniConversion.cxx
index dea069843..0d69d9969 100644
--- a/src/UniConversion.cxx
+++ b/src/UniConversion.cxx
@@ -17,7 +17,6 @@ using namespace Scintilla;
namespace Scintilla {
#endif
-enum { SURROGATE_LEAD_FIRST = 0xD800 };
enum { SURROGATE_TRAIL_FIRST = 0xDC00 };
enum { SURROGATE_TRAIL_LAST = 0xDFFF };
enum { SUPPLEMENTAL_PLANE_FIRST = 0x10000 };
@@ -43,7 +42,7 @@ unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) {
}
void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len) {
- int k = 0;
+ unsigned int k = 0;
for (unsigned int i = 0; i < tlen && uptr[i];) {
unsigned int uch = uptr[i];
if (uch < 0x80) {
@@ -67,7 +66,8 @@ void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned
}
i++;
}
- putf[len] = '\0';
+ if (k < len)
+ putf[k] = '\0';
}
unsigned int UTF8CharLength(unsigned char ch) {
diff --git a/src/UniConversion.h b/src/UniConversion.h
index 8c7ac4a27..08898cac3 100644
--- a/src/UniConversion.h
+++ b/src/UniConversion.h
@@ -55,6 +55,12 @@ inline bool UTF8IsNEL(const unsigned char *us) {
return (us[0] == 0xc2) && (us[1] == 0x85);
}
+enum { SURROGATE_LEAD_FIRST = 0xD800 };
+enum { SURROGATE_LEAD_LAST = 0xDBFF };
+inline unsigned int UTF16CharLength(wchar_t uch) {
+ return ((uch >= SURROGATE_LEAD_FIRST) && (uch <= SURROGATE_LEAD_LAST)) ? 2 : 1;
+}
+
#ifdef SCI_NAMESPACE
}
#endif