aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Editor.cxx61
-rw-r--r--src/Editor.h2
-rw-r--r--src/ScintillaBase.cxx4
-rw-r--r--src/ScintillaBase.h2
4 files changed, 37 insertions, 32 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index f9afa81a1..44df21c99 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -1914,7 +1914,7 @@ void Editor::AddChar(char ch) {
AddCharUTF(s, 1);
}
-void Editor::AddCharUTF(char *s, unsigned int len) {
+void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
bool wasSelection = currentPos != anchor;
ClearSelection();
if (inOverstrike && !wasSelection) {
@@ -1931,37 +1931,42 @@ void Editor::AddCharUTF(char *s, unsigned int len) {
ShowCaretAtCurrentPosition();
SetLastXChosen();
- int byte = static_cast<unsigned char>(s[0]);
- if ((byte < 0xC0) || (1 == len)) {
- // Handles UTF-8 characters between 0x01 and 0x7F and single byte
- // characters when not in UTF-8 mode.
- // Also treats \0 and naked trail bytes 0x80 to 0xBF as valid
- // characters representing themselves.
+ if (treatAsDBCS) {
+ NotifyChar((static_cast<unsigned char>(s[0]) << 8) |
+ static_cast<unsigned char>(s[1]));
} else {
- // Unroll 1 to 3 byte UTF-8 sequences. See reference data at:
- // http://www.cl.cam.ac.uk/~mgk25/unicode.html
- // http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
- if (byte < 0xE0) {
- int byte2 = static_cast<unsigned char>(s[1]);
- if ((byte2 & 0xC0) == 0x80) {
- // Two-byte-character lead-byte followed by a trail-byte.
- byte = (((byte & 0x1F) << 6) | (byte2 & 0x3F));
- }
- // A two-byte-character lead-byte not followed by trail-byte
- // represents itself.
- } else if (byte < 0xF0) {
- int byte2 = static_cast<unsigned char>(s[1]);
- int byte3 = static_cast<unsigned char>(s[2]);
- if (((byte2 & 0xC0) == 0x80) && ((byte3 & 0xC0) == 0x80)) {
- // Three-byte-character lead byte followed by two trail bytes.
- byte = (((byte & 0x0F) << 12) | ((byte2 & 0x3F) << 6) |
- (byte3 & 0x3F));
+ int byte = static_cast<unsigned char>(s[0]);
+ if ((byte < 0xC0) || (1 == len)) {
+ // Handles UTF-8 characters between 0x01 and 0x7F and single byte
+ // characters when not in UTF-8 mode.
+ // Also treats \0 and naked trail bytes 0x80 to 0xBF as valid
+ // characters representing themselves.
+ } else {
+ // Unroll 1 to 3 byte UTF-8 sequences. See reference data at:
+ // http://www.cl.cam.ac.uk/~mgk25/unicode.html
+ // http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
+ if (byte < 0xE0) {
+ int byte2 = static_cast<unsigned char>(s[1]);
+ if ((byte2 & 0xC0) == 0x80) {
+ // Two-byte-character lead-byte followed by a trail-byte.
+ byte = (((byte & 0x1F) << 6) | (byte2 & 0x3F));
+ }
+ // A two-byte-character lead-byte not followed by trail-byte
+ // represents itself.
+ } else if (byte < 0xF0) {
+ int byte2 = static_cast<unsigned char>(s[1]);
+ int byte3 = static_cast<unsigned char>(s[2]);
+ if (((byte2 & 0xC0) == 0x80) && ((byte3 & 0xC0) == 0x80)) {
+ // Three-byte-character lead byte followed by two trail bytes.
+ byte = (((byte & 0x0F) << 12) | ((byte2 & 0x3F) << 6) |
+ (byte3 & 0x3F));
+ }
+ // A three-byte-character lead-byte not followed by two trail-bytes
+ // represents itself.
}
- // A three-byte-character lead-byte not followed by two trail-bytes
- // represents itself.
}
+ NotifyChar(byte);
}
- NotifyChar(byte);
}
void Editor::ClearSelection() {
diff --git a/src/Editor.h b/src/Editor.h
index a9da3f9a1..1e2310513 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -295,7 +295,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void ChangeSize();
void AddChar(char ch);
- virtual void AddCharUTF(char *s, unsigned int len);
+ virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
void ClearSelection();
void ClearAll();
void ClearDocumentStyle();
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index fe732cabd..6b2bd8553 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -63,10 +63,10 @@ void ScintillaBase::RefreshColourPalette(Palette &pal, bool want) {
ct.RefreshColourPalette(pal, want);
}
-void ScintillaBase::AddCharUTF(char *s, unsigned int len) {
+void ScintillaBase::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
bool acActiveBeforeCharAdded = ac.Active();
if (!acActiveBeforeCharAdded || !ac.IsFillUpChar(*s))
- Editor::AddCharUTF(s, len);
+ Editor::AddCharUTF(s, len, treatAsDBCS);
if (acActiveBeforeCharAdded)
AutoCompleteChanged(s[0]);
}
diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h
index 375cc9a74..0c1f6fee9 100644
--- a/src/ScintillaBase.h
+++ b/src/ScintillaBase.h
@@ -57,7 +57,7 @@ protected:
virtual void RefreshColourPalette(Palette &pal, bool want);
- virtual void AddCharUTF(char *s, unsigned int len);
+ virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
void Command(int cmdId);
virtual void CancelModes();
virtual int KeyCommand(unsigned int iMessage);