diff options
Diffstat (limited to 'backends/platform/sdl')
-rw-r--r-- | backends/platform/sdl/macosx/macosx_wrapper.mm | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/backends/platform/sdl/macosx/macosx_wrapper.mm b/backends/platform/sdl/macosx/macosx_wrapper.mm index 0a1478fe59..32dfa040cc 100644 --- a/backends/platform/sdl/macosx/macosx_wrapper.mm +++ b/backends/platform/sdl/macosx/macosx_wrapper.mm @@ -24,11 +24,13 @@ #define FORBIDDEN_SYMBOL_ALLOW_ALL #include "backends/platform/sdl/macosx/macosx_wrapper.h" +#include "common/translation.h" #include <AppKit/NSPasteboard.h> #include <Foundation/NSArray.h> #include <Foundation/NSPathUtilities.h> #include <AvailabilityMacros.h> +#include <CoreFoundation/CFString.h> bool hasTextInClipboardMacOSX() { return [[NSPasteboard generalPasteboard] availableTypeFromArray:[NSArray arrayWithObject:NSStringPboardType]] != nil; @@ -43,16 +45,30 @@ Common::String getTextFromClipboardMacOSX() { NSString *str = [pb stringForType:NSStringPboardType]; if (str == nil) return Common::String(); - // If the string cannot be represented using the requested encoding we get a null pointer below. - // This is fine as ScummVM would not know what to do with non-ASCII characters (although maybe - // we should use NSISOLatin1StringEncoding?). - return Common::String([str cStringUsingEncoding:NSASCIIStringEncoding]); + + // If translations are supported, use the current TranslationManager charset and otherwise + // use ASCII. If the string cannot be represented using the requested encoding we get a null + // pointer below, which is fine as ScummVM would not know what to do with the string anyway. +#ifdef USE_TRANSLATION + NSString* encStr = [NSString stringWithCString:TransMan.getCurrentCharset().c_str() encoding:NSASCIIStringEncoding]; + NSStringEncoding encoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)encStr)); +#else + NSStringEncoding encoding = NSISOLatin1StringEncoding; +#endif + return Common::String([str cStringUsingEncoding:encoding]); } bool setTextInClipboardMacOSX(const Common::String &text) { NSPasteboard *pb = [NSPasteboard generalPasteboard]; [pb declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil]; - return [pb setString:[NSString stringWithCString:text.c_str() encoding:NSASCIIStringEncoding] forType:NSStringPboardType]; + +#ifdef USE_TRANSLATION + NSString* encStr = [NSString stringWithCString:TransMan.getCurrentCharset().c_str() encoding:NSASCIIStringEncoding]; + NSStringEncoding encoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)encStr)); +#else + NSStringEncoding encoding = NSISOLatin1StringEncoding; +#endif + return [pb setString:[NSString stringWithCString:text.c_str() encoding:encoding] forType:NSStringPboardType]; } Common::String getDesktopPathMacOSX() { |