Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions py-appscript/trunk/appscript_2x/ext/ae.c
Original file line number Diff line number Diff line change
Expand Up @@ -1032,21 +1032,12 @@ static int AE_GetCFStringRef(PyObject *v, CFStringRef *p_itself)
return 1;
}
if (PyUnicode_Check(v)) {
#ifdef Py_UNICODE_WIDE
CFIndex size = PyUnicode_GET_DATA_SIZE(v);
UTF32Char *unichars = PyUnicode_AsUnicode(v);
*p_itself = CFStringCreateWithBytes((CFAllocatorRef)NULL,
unichars,
size,
kCFStringEncodingUTF32, // 10.4+
false); // ?
#else
CFIndex size = PyUnicode_GetSize(v);
UniChar *unichars = PyUnicode_AsUnicode(v);
if (!unichars) return 0;
*p_itself = CFStringCreateWithCharacters((CFAllocatorRef)NULL, unichars, size);
#endif
return 1;
char *cStr;
if (!PyArg_Parse(v, "es", NULL, &cStr))
return 0;
*p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingUTF8);
PyMem_Free(cStr);
return 1;
}
PyErr_SetString(PyExc_TypeError, "str/unicode required");
return 0;
Expand Down
21 changes: 6 additions & 15 deletions py-appscript/trunk/appscript_3x/ext/ae.c
Original file line number Diff line number Diff line change
Expand Up @@ -1010,21 +1010,12 @@ static int AE_GetCFStringRef(PyObject *v, CFStringRef *p_itself)
return 1;
}
if (PyUnicode_Check(v)) {
#ifdef Py_UNICODE_WIDE
CFIndex size = PyUnicode_GET_DATA_SIZE(v);
UTF32Char *unichars = PyUnicode_AsUnicode(v);
*p_itself = CFStringCreateWithBytes((CFAllocatorRef)NULL,
unichars,
size,
kCFStringEncodingUTF32, // 10.4+
false); // ?
#else
CFIndex size = PyUnicode_GetSize(v);
UniChar *unichars = PyUnicode_AsUnicode(v);
if (!unichars) return 0;
*p_itself = CFStringCreateWithCharacters((CFAllocatorRef)NULL, unichars, size);
#endif
return 1;
char *cStr;
if (!PyArg_Parse(v, "es", NULL, &cStr))
return 0;
*p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingUTF8);
PyMem_Free(cStr);
return 1;
}
PyErr_SetString(PyExc_TypeError, "str/unicode required");
return 0;
Expand Down