mirror of
https://github.com/glfw/glfw.git
synced 2025-06-15 04:02:31 +00:00
macOS: Use UTF-32 for preedit text encoding
The char stream of GLFW API must be UTF-32.
This commit is contained in:
parent
dcfde1a0db
commit
68c977ee4d
@ -696,7 +696,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
|
|
||||||
NSString* markedTextString = markedText.string;
|
NSString* markedTextString = markedText.string;
|
||||||
|
|
||||||
NSUInteger i, length = [markedTextString length];
|
NSUInteger length = [markedTextString length];
|
||||||
int ctext = window->ctext;
|
int ctext = window->ctext;
|
||||||
while (ctext < length + 1)
|
while (ctext < length + 1)
|
||||||
{
|
{
|
||||||
@ -711,13 +711,30 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
window->preeditText = preeditText;
|
window->preeditText = preeditText;
|
||||||
window->ctext = ctext;
|
window->ctext = ctext;
|
||||||
}
|
}
|
||||||
window->ntext = length;
|
|
||||||
window->preeditText[length] = 0;
|
NSInteger preeditTextLength = 0;
|
||||||
for (i = 0; i < length; i++)
|
NSRange range = NSMakeRange(0, length);
|
||||||
|
while (range.length)
|
||||||
{
|
{
|
||||||
const unichar codepoint = [markedTextString characterAtIndex:i];
|
uint32_t codepoint = 0;
|
||||||
window->preeditText[i] = codepoint;
|
|
||||||
|
if ([markedTextString getBytes:&codepoint
|
||||||
|
maxLength:sizeof(codepoint)
|
||||||
|
usedLength:NULL
|
||||||
|
encoding:NSUTF32StringEncoding
|
||||||
|
options:0
|
||||||
|
range:range
|
||||||
|
remainingRange:&range])
|
||||||
|
{
|
||||||
|
if (codepoint >= 0xf700 && codepoint <= 0xf7ff)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
window->preeditText[preeditTextLength++] = codepoint;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
window->ntext = preeditTextLength;
|
||||||
|
window->preeditText[preeditTextLength] = 0;
|
||||||
|
|
||||||
int focusedBlock = 0;
|
int focusedBlock = 0;
|
||||||
NSInteger offset = 0;
|
NSInteger offset = 0;
|
||||||
window->nblocks = 0;
|
window->nblocks = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user