mirror of
https://github.com/python/cpython.git
synced 2025-10-23 15:12:02 +00:00
Patch #632973: Implement _getdefaultlocale for OS X.
This commit is contained in:
parent
318b7b920d
commit
52ea7e9244
2 changed files with 19 additions and 8 deletions
|
|
@ -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)
|
||||||
}
|
}
|
||||||
#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[] = {
|
||||||
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.
|
||||||
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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue