mirror of https://github.com/encounter/SDL.git
cocoa: Report an error if SDL_SetClipboardText() isn't using UTF-8 encoding.
Fixes #4110.
This commit is contained in:
parent
107db2d899
commit
9dc97afa71
|
@ -32,10 +32,14 @@ Cocoa_SetClipboardText(_THIS, const char *text)
|
|||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
NSPasteboard *pasteboard;
|
||||
NSString *format = NSPasteboardTypeString;
|
||||
NSString *nsstr = [NSString stringWithUTF8String:text];
|
||||
if (nsstr == nil) {
|
||||
return SDL_SetError("Couldn't create NSString; is your string data in UTF-8 format?");
|
||||
}
|
||||
|
||||
pasteboard = [NSPasteboard generalPasteboard];
|
||||
data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
|
||||
[pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
|
||||
[pasteboard setString:nsstr forType:format];
|
||||
|
||||
return 0;
|
||||
}}
|
||||
|
@ -61,7 +65,7 @@ Cocoa_GetClipboardText(_THIS)
|
|||
} else {
|
||||
utf8 = [string UTF8String];
|
||||
}
|
||||
text = SDL_strdup(utf8);
|
||||
text = SDL_strdup(utf8 ? utf8 : "");
|
||||
} else {
|
||||
text = SDL_strdup("");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue