macOS: make Ime::Preedit cursor range surrogate-safe in setMarkedText
`setMarkedText:selectedRange:replacementRange:` converted the IME's UTF-16 `selectedRange` into UTF-8 byte offsets by taking `substringToIndex:` prefixes and measuring them with `NSString::len()` (`lengthOfBytesUsingEncoding:NSUTF8StringEncoding`). When an index falls inside a surrogate pair, the prefix ends in a lone high surrogate, which UTF-8 cannot represent, so `lengthOfBytesUsingEncoding:` returns 0 for the entire prefix and the offset silently collapses to 0.
W
William-Selna committed
4ef144b519e1da2fe9080267fdb7be1515a9c9c6
Parent: 7fe8c20
Committed by GitHub <noreply@github.com>
on 6/19/2026, 4:34:43 PM