Skip to content

Commit

Permalink
make start&length represent utf32 indices
Browse files Browse the repository at this point in the history
  • Loading branch information
williamhCode authored and slouken committed Feb 21, 2025
1 parent 9d06145 commit 9a607e8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/video/cocoa/SDL_cocoakeyboard.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,12 @@ - (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replaceme
// This key event was consumed by the IME
[self clearPendingKey];

NSUInteger utf32SelectedRangeLocation = [[aString substringToIndex:selectedRange.location] lengthOfBytesUsingEncoding:NSUTF32StringEncoding] / 4;
NSUInteger utf32SelectionRangeEnd = [[aString substringToIndex:(selectedRange.location + selectedRange.length)] lengthOfBytesUsingEncoding:NSUTF32StringEncoding] / 4;
NSUInteger utf32SelectionRangeLength = utf32SelectionRangeEnd - utf32SelectedRangeLocation;

SDL_SendEditingText([aString UTF8String],
(int)selectedRange.location, (int)selectedRange.length);
(int)utf32SelectedRangeLocation, (int)utf32SelectionRangeLength);

DEBUG_IME(@"setMarkedText: %@, (%d, %d) replacement range (%d, %d)", _markedText,
(int)selectedRange.location, (int)selectedRange.length,
Expand Down

0 comments on commit 9a607e8

Please sign in to comment.