From 52ea7e9244f673602a32beb4c0489bfdd59cb1d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Tue, 26 Nov 2002 09:05:36 +0000 Subject: Patch #632973: Implement _getdefaultlocale for OS X. --- Python/mactoolboxglue.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'Python/mactoolboxglue.c') diff --git a/Python/mactoolboxglue.c b/Python/mactoolboxglue.c index fc1d1afde1..6d39d57d51 100644 --- a/Python/mactoolboxglue.c +++ b/Python/mactoolboxglue.c @@ -38,11 +38,22 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. char *PyMac_getscript() { #if TARGET_API_MAC_OSX - /* We cannot use GetSysFont because it requires the window manager - ** There are other APIs to query the default 8 bit encoding, but - ** I don't know about them (yet). - */ - return "ascii"; + CFStringEncoding enc = CFStringGetSystemEncoding(); + static CFStringRef name = NULL; + /* Return the code name for the encodings for which we have codecs. */ + switch(enc) { + case kCFStringEncodingMacRoman: return "mac-roman"; + case kCFStringEncodingMacGreek: return "mac-greek"; + case kCFStringEncodingMacCyrillic: return "mac-cyrillic"; + case kCFStringEncodingMacTurkish: return "mac-turkish"; + case kCFStringEncodingMacIcelandic: return "mac-icelandic"; + /* XXX which one is mac-latin2? */ + } + if (!name) { + /* This leaks a an object. */ + name = CFStringConvertEncodingToIANACharSetName(enc); + } + return CFStringGetCStringPtr(name, 0); #else int font, script, lang; font = 0; -- cgit v1.2.1