aboutsummaryrefslogtreecommitdiffhomepage
path: root/cocoa/ScintillaCocoa.mm
diff options
context:
space:
mode:
Diffstat (limited to 'cocoa/ScintillaCocoa.mm')
-rw-r--r--cocoa/ScintillaCocoa.mm13
1 files changed, 12 insertions, 1 deletions
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm
index ec78479b9..8d061205a 100644
--- a/cocoa/ScintillaCocoa.mm
+++ b/cocoa/ScintillaCocoa.mm
@@ -2284,7 +2284,18 @@ ptrdiff_t ScintillaCocoa::InsertText(NSString *input) {
if (encoded.length() > 0)
{
- AddCharUTF(encoded.c_str(), static_cast<unsigned int>(encoded.length()), false);
+ if (encoding == kCFStringEncodingUTF8) {
+ // There may be multiple characters in input so loop over them
+ std::string sv = encoded;
+ while (sv.length()) {
+ const unsigned char leadByte = sv[0];
+ const unsigned int bytesInCharacter = UTF8BytesOfLead[leadByte];
+ AddCharUTF(sv.c_str(), bytesInCharacter, false);
+ sv = sv.substr(bytesInCharacter, sv.length());
+ }
+ } else {
+ AddCharUTF(encoded.c_str(), static_cast<unsigned int>(encoded.length()), false);
+ }
}
return encoded.length();
}