aboutsummaryrefslogtreecommitdiffhomepage
path: root/cocoa
diff options
context:
space:
mode:
Diffstat (limited to 'cocoa')
-rw-r--r--cocoa/ScintillaCocoa.mm13
1 files changed, 12 insertions, 1 deletions
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm
index 1338a66fa..9a7125023 100644
--- a/cocoa/ScintillaCocoa.mm
+++ b/cocoa/ScintillaCocoa.mm
@@ -2179,7 +2179,18 @@ ptrdiff_t ScintillaCocoa::InsertText(NSString *input) {
std::string encoded = EncodedBytesString((__bridge CFStringRef)input, encoding);
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_view sv = encoded;
+ while (sv.length()) {
+ const unsigned char leadByte = sv[0];
+ const unsigned int bytesInCharacter = UTF8BytesOfLead[leadByte];
+ AddCharUTF(sv.data(), bytesInCharacter, false);
+ sv.remove_prefix(bytesInCharacter);
+ }
+ } else {
+ AddCharUTF(encoded.c_str(), static_cast<unsigned int>(encoded.length()), false);
+ }
}
return encoded.length();
}