aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gtk/PlatGTK.cxx33
-rw-r--r--gtk/ScintillaGTK.cxx7
2 files changed, 32 insertions, 8 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index 97b085587..eb11b504b 100644
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -2733,16 +2733,35 @@ long Platform::SendScintillaPointer(
reinterpret_cast<sptr_t>(lParam));
}
-bool Platform::IsDBCSLeadByte(int /* codePage */, char /* ch */) {
+bool Platform::IsDBCSLeadByte(int codePage, char ch) {
+ // Byte ranges found in Wikipedia articles with relevant search strings in each case
+ unsigned char uch = static_cast<unsigned char>(ch);
+ switch (codePage) {
+ case 932:
+ // Shift_jis
+ return ((uch >= 0x81) && (uch <= 0x9F)) ||
+ ((uch >= 0xE0) && (uch <= 0xEF));
+ case 936:
+ // GBK
+ return (uch >= 0x81) && (uch <= 0xFE);
+ case 950:
+ // Big5
+ return (uch >= 0x81) && (uch <= 0xFE);
+ // Korean EUC-KR may be code page 949.
+ }
return false;
}
-int Platform::DBCSCharLength(int, const char *s) {
- int bytes = mblen(s, MB_CUR_MAX);
- if (bytes >= 1)
- return bytes;
- else
- return 1;
+int Platform::DBCSCharLength(int codePage, const char *s) {
+ if (codePage == 932 || codePage == 936 || codePage == 950) {
+ return IsDBCSLeadByte(codePage, s[0]) ? 2 : 1;
+ } else {
+ int bytes = mblen(s, MB_CUR_MAX);
+ if (bytes >= 1)
+ return bytes;
+ else
+ return 1;
+ }
}
int Platform::DBCSCharMaxLength() {
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx
index b490975e8..ab9c9d58a 100644
--- a/gtk/ScintillaGTK.cxx
+++ b/gtk/ScintillaGTK.cxx
@@ -1001,7 +1001,12 @@ int ScintillaGTK::EncodedFromUTF8(char *utf8, char *encoded) {
}
bool ScintillaGTK::ValidCodePage(int codePage) const {
- return codePage == 0 || codePage == SC_CP_UTF8 || codePage == SC_CP_DBCS;
+ return codePage == 0
+ || codePage == SC_CP_UTF8
+ || codePage == 932
+ || codePage == 936
+ || codePage == 950
+ || codePage == SC_CP_DBCS;
}
sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {