numpy 2.0.0
src/multiarray/ucsnarrow.c File Reference
#include <Python.h>
#include <locale.h>
#include <stdio.h>
#include "numpy/arrayobject.h"
#include "numpy/npy_math.h"
#include "npy_config.h"
#include "numpy/npy_3kcompat.h"

Defines

#define PY_SSIZE_T_CLEAN
#define NPY_NO_DEPRECATED_API
#define _MULTIARRAYMODULE
#define NPY_NO_PREFIX

Functions

NPY_NO_EXPORT int PyUCS2Buffer_FromUCS4 (Py_UNICODE *ucs2, PyArray_UCS4 *ucs4, int ucs4length)
NPY_NO_EXPORT int PyUCS2Buffer_AsUCS4 (Py_UNICODE *ucs2, PyArray_UCS4 *ucs4, int ucs2len, int ucs4len)
NPY_NO_EXPORT PyObject * MyPyUnicode_New (int length)
NPY_NO_EXPORT int MyPyUnicode_Resize (PyUnicodeObject *uni, int length)

Define Documentation

#define _MULTIARRAYMODULE
#define NPY_NO_DEPRECATED_API
#define NPY_NO_PREFIX
#define PY_SSIZE_T_CLEAN

Function Documentation

NPY_NO_EXPORT PyObject* MyPyUnicode_New ( int  length)
NPY_NO_EXPORT int MyPyUnicode_Resize ( PyUnicodeObject *  uni,
int  length 
)
NPY_NO_EXPORT int PyUCS2Buffer_AsUCS4 ( Py_UNICODE *  ucs2,
PyArray_UCS4 *  ucs4,
int  ucs2len,
int  ucs4len 
)
This converts a UCS2 buffer of the given length to UCS4 buffer.

It converts up to ucs4len characters of UCS2

It returns the number of characters converted which can be less than ucs2len if there are surrogate pairs in ucs2.

The return value is the actual size of the used part of the ucs4 buffer.

surrogate pair

<

-0xdc00 + 0x10000

NPY_NO_EXPORT int PyUCS2Buffer_FromUCS4 ( Py_UNICODE *  ucs2,
PyArray_UCS4 *  ucs4,
int  ucs4length 
)
Functions only needed on narrow builds of Python
for converting back and forth between the NumPy Unicode data-type (always 4-byte) and the Python Unicode scalar (2-bytes on a narrow build).
the ucs2 buffer must be large enough to hold 2*ucs4length characters

due to the use of surrogate pairs.

The return value is the number of ucs2 bytes used-up which is ucs4length + number of surrogate pairs found.

values above 0xffff are converted to surrogate pairs.