Fix icu_character_name not working for non-BMP chars on windows

This commit is contained in:
Kovid Goyal 2014-03-06 19:05:57 +05:30
parent 4b954101b7
commit efafb69fcd

View File

@ -697,7 +697,7 @@ icu_get_available_transliterators(PyObject *self, PyObject *args) {
static PyObject * static PyObject *
icu_character_name(PyObject *self, PyObject *args) { icu_character_name(PyObject *self, PyObject *args) {
char name[512] = {0}; char name[512] = {0};
int32_t sz, alias = 0; int32_t sz = 0, alias = 0;
UChar *buf; UChar *buf;
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
PyObject *palias = NULL, *result = NULL, *input = NULL; PyObject *palias = NULL, *result = NULL, *input = NULL;
@ -706,9 +706,9 @@ icu_character_name(PyObject *self, PyObject *args) {
if (!PyArg_ParseTuple(args, "O|O", &input, &palias)) return NULL; if (!PyArg_ParseTuple(args, "O|O", &input, &palias)) return NULL;
if (palias != NULL && PyObject_IsTrue(palias)) alias = 1; if (palias != NULL && PyObject_IsTrue(palias)) alias = 1;
buf = python_to_icu(input, NULL, 1); buf = python_to_icu(input, &sz, 1);
if (buf == NULL) goto end; if (buf == NULL) goto end;
U16_GET(buf, 0, 0, -1, code); U16_GET(buf, 0, 0, sz, code);
if (alias) { if (alias) {
sz = u_charName(code, U_CHAR_NAME_ALIAS, name, 511, &status); sz = u_charName(code, U_CHAR_NAME_ALIAS, name, 511, &status);
} else { } else {