mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-03 11:12:27 +00:00
Update Musl Libc code
We now have implement all of Musl's localization code, the same way that Musl implements localization. You may need setlocale(LC_ALL, "C.UTF-8"), just in case anything stops working as expected.
This commit is contained in:
parent
d0360bf4bd
commit
bb815eafaf
116 changed files with 6525 additions and 5523 deletions
31
third_party/python/Objects/unicodeobject.c
vendored
31
third_party/python/Objects/unicodeobject.c
vendored
|
@ -3158,6 +3158,37 @@ PyUnicode_AsWideCharString(PyObject *unicode,
|
|||
return buffer;
|
||||
}
|
||||
|
||||
wchar_t*
|
||||
_PyUnicode_AsWideCharString(PyObject *unicode)
|
||||
{
|
||||
const wchar_t *wstr;
|
||||
wchar_t *buffer;
|
||||
Py_ssize_t buflen;
|
||||
|
||||
if (unicode == NULL) {
|
||||
PyErr_BadInternalCall();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wstr = PyUnicode_AsUnicodeAndSize(unicode, &buflen);
|
||||
if (wstr == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (wcslen(wstr) != (size_t)buflen) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"embedded null character");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buffer = PyMem_NEW(wchar_t, buflen + 1);
|
||||
if (buffer == NULL) {
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
}
|
||||
memcpy(buffer, wstr, (buflen + 1) * sizeof(wchar_t));
|
||||
return buffer;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
PyUnicode_FromOrdinal(int ordinal)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue