#include <windows.h>
#endif
-#ifdef macintosh
+#if __APPLE__
#include "macglue.h"
#endif
}
#endif
-#if defined(macintosh)
+#if defined(__APPLE__)
static PyObject*
PyLocale_getdefaultlocale(PyObject* self)
{
METH_VARARGS, strcoll__doc__},
{"strxfrm", (PyCFunction) PyLocale_strxfrm,
METH_VARARGS, strxfrm__doc__},
-#if defined(MS_WINDOWS) || defined(macintosh)
+#if defined(MS_WINDOWS) || defined(__APPLE__)
{"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, METH_NOARGS},
#endif
#ifdef HAVE_LANGINFO_H
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;