summaryrefslogtreecommitdiff
path: root/Modules/_localemodule.c
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2004-07-15 13:31:39 +0000
committerJack Jansen <jack.jansen@cwi.nl>2004-07-15 13:31:39 +0000
commit59f072ad7c7b56a1e803a74ba59d869b838c256f (patch)
tree0e9cd92ad9c423e8ab54d7bd23786fbc1b802dab /Modules/_localemodule.c
parent75694501cae16b6a688bba2e6fb3fd1f0d3ba22f (diff)
downloadcpython-git-59f072ad7c7b56a1e803a74ba59d869b838c256f.tar.gz
Moved PyMac_GetScript() to _localemodule, which is the only place where
it is used, and made it private. Should fix #978662.
Diffstat (limited to 'Modules/_localemodule.c')
-rw-r--r--Modules/_localemodule.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c
index 0ab79cba60..0f8a71aadc 100644
--- a/Modules/_localemodule.c
+++ b/Modules/_localemodule.c
@@ -30,7 +30,7 @@ This software comes with no warranty. Use at your own risk.
#endif
#if defined(__APPLE__)
-#include "pymactoolbox.h"
+#include <CoreFoundation/CoreFoundation.h>
#endif
#if defined(MS_WINDOWS)
@@ -406,10 +406,34 @@ PyLocale_getdefaultlocale(PyObject* self)
#endif
#if defined(__APPLE__)
+/*
+** Find out what the current script is.
+** Donated by Fredrik Lund.
+*/
+static char *mac_getscript(void)
+{
+ 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 (char *)CFStringGetCStringPtr(name, 0);
+}
+
static PyObject*
PyLocale_getdefaultlocale(PyObject* self)
{
- return Py_BuildValue("Os", Py_None, PyMac_getscript());
+ return Py_BuildValue("Os", Py_None, mac_getscript());
}
#endif