aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/DBCS.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2017-06-12 11:49:56 +1000
committerNeil <nyamatongwe@gmail.com>2017-06-12 11:49:56 +1000
commit46f9fd7509eaa2809392acf3a264b57a2daf973c (patch)
tree1e3ee8a900c4e4c7768abbe21bfa9acc4043b345 /src/DBCS.cxx
parent09972b3a179d7ea39ef6ce7e0474531797c549fb (diff)
downloadscintilla-mirror-46f9fd7509eaa2809392acf3a264b57a2daf973c.tar.gz
Removed unused functions and methods from Platform.h.
Replaced Platform::Clamp with Sci::clamp but will later change this to std::clamp once on full C++17 compilers. Drop MouseButtonBounce workaround for very early GTK+/Linux.
Diffstat (limited to 'src/DBCS.cxx')
-rw-r--r--src/DBCS.cxx48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/DBCS.cxx b/src/DBCS.cxx
new file mode 100644
index 000000000..46cee8e69
--- /dev/null
+++ b/src/DBCS.cxx
@@ -0,0 +1,48 @@
+// Scintilla source code edit control
+/** @file DBCS.cxx
+ ** Functions to handle DBCS double byte encodings like Shift-JIS.
+ **/
+// Copyright 2017 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include "DBCS.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
+bool DBCSIsLeadByte(int codePage, char ch) {
+ // Byte ranges found in Wikipedia articles with relevant search strings in each case
+ const unsigned char uch = static_cast<unsigned char>(ch);
+ switch (codePage) {
+ case 932:
+ // Shift_jis
+ return ((uch >= 0x81) && (uch <= 0x9F)) ||
+ ((uch >= 0xE0) && (uch <= 0xFC));
+ // Lead bytes F0 to FC may be a Microsoft addition.
+ case 936:
+ // GBK
+ return (uch >= 0x81) && (uch <= 0xFE);
+ case 949:
+ // Korean Wansung KS C-5601-1987
+ return (uch >= 0x81) && (uch <= 0xFE);
+ case 950:
+ // Big5
+ return (uch >= 0x81) && (uch <= 0xFE);
+ case 1361:
+ // Korean Johab KS C-5601-1992
+ return
+ ((uch >= 0x84) && (uch <= 0xD3)) ||
+ ((uch >= 0xD8) && (uch <= 0xDE)) ||
+ ((uch >= 0xE0) && (uch <= 0xF9));
+ }
+ return false;
+}
+
+#ifdef SCI_NAMESPACE
+}
+#endif