Cocoa: Fix non-BMP Unicode codepoint input

Supplimentary Plane codepoints were reported as UTF-16 surrogate pairs.

Fixes #1635.
This commit is contained in:
Camilla Löwy
2020-06-29 21:16:59 +02:00
parent 854ce1db4e
commit ad9eb768c9
2 changed files with 19 additions and 6 deletions
+16 -6
View File
@@ -731,14 +731,24 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
else
characters = (NSString*) string;
const NSUInteger length = [characters length];
for (NSUInteger i = 0; i < length; i++)
NSRange range = NSMakeRange(0, [characters length]);
while (range.length)
{
const unichar codepoint = [characters characterAtIndex:i];
if ((codepoint & 0xff00) == 0xf700)
continue;
uint32_t codepoint = 0;
_glfwInputChar(window, codepoint, mods, plain);
if ([characters getBytes:&codepoint
maxLength:sizeof(codepoint)
usedLength:NULL
encoding:NSUTF32StringEncoding
options:0
range:range
remainingRange:&range])
{
if ((codepoint & 0xff00) == 0xf700)
continue;
_glfwInputChar(window, codepoint, mods, plain);
}
}
}