Commit 52ea7e92 authored by Martin v. Löwis's avatar Martin v. Löwis

Patch #632973: Implement _getdefaultlocale for OS X.

parent 318b7b92
...@@ -30,7 +30,7 @@ This software comes with no warranty. Use at your own risk. ...@@ -30,7 +30,7 @@ This software comes with no warranty. Use at your own risk.
#include <windows.h> #include <windows.h>
#endif #endif
#ifdef macintosh #if __APPLE__
#include "macglue.h" #include "macglue.h"
#endif #endif
...@@ -400,7 +400,7 @@ PyLocale_getdefaultlocale(PyObject* self) ...@@ -400,7 +400,7 @@ PyLocale_getdefaultlocale(PyObject* self)
} }
#endif #endif
#if defined(macintosh) #if defined(__APPLE__)
static PyObject* static PyObject*
PyLocale_getdefaultlocale(PyObject* self) PyLocale_getdefaultlocale(PyObject* self)
{ {
...@@ -627,7 +627,7 @@ static struct PyMethodDef PyLocale_Methods[] = { ...@@ -627,7 +627,7 @@ static struct PyMethodDef PyLocale_Methods[] = {
METH_VARARGS, strcoll__doc__}, METH_VARARGS, strcoll__doc__},
{"strxfrm", (PyCFunction) PyLocale_strxfrm, {"strxfrm", (PyCFunction) PyLocale_strxfrm,
METH_VARARGS, strxfrm__doc__}, METH_VARARGS, strxfrm__doc__},
#if defined(MS_WINDOWS) || defined(macintosh) #if defined(MS_WINDOWS) || defined(__APPLE__)
{"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, METH_NOARGS}, {"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, METH_NOARGS},
#endif #endif
#ifdef HAVE_LANGINFO_H #ifdef HAVE_LANGINFO_H
......
...@@ -38,11 +38,22 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -38,11 +38,22 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
char *PyMac_getscript() char *PyMac_getscript()
{ {
#if TARGET_API_MAC_OSX #if TARGET_API_MAC_OSX
/* We cannot use GetSysFont because it requires the window manager CFStringEncoding enc = CFStringGetSystemEncoding();
** There are other APIs to query the default 8 bit encoding, but static CFStringRef name = NULL;
** I don't know about them (yet). /* Return the code name for the encodings for which we have codecs. */
*/ switch(enc) {
return "ascii"; 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 #else
int font, script, lang; int font, script, lang;
font = 0; font = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment