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
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,7 @@ Victor Salgado
Rich Salz
Kevin Samborn
Adrian Sampson
Guillaume Sanchez
Nevada Sanchez
James Sanders
Ilya Sandler
Expand Down
62 changes: 61 additions & 1 deletion Modules/clinic/unicodedata.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,33 @@ unicodedata_UCD_east_asian_width(PyObject *self, PyObject *arg)
return return_value;
}

PyDoc_STRVAR(unicodedata_UCD_grapheme_cluster_break__doc__,
"grapheme_cluster_break($self, chr, /)\n"
"--\n"
"\n"
"Returns the GraphemeBreakProperty assigned to the character chr as string.");

#define UNICODEDATA_UCD_GRAPHEME_CLUSTER_BREAK_METHODDEF \
{"grapheme_cluster_break", (PyCFunction)unicodedata_UCD_grapheme_cluster_break, METH_O, unicodedata_UCD_grapheme_cluster_break__doc__},

static PyObject *
unicodedata_UCD_grapheme_cluster_break_impl(PyObject *self, int chr);

static PyObject *
unicodedata_UCD_grapheme_cluster_break(PyObject *self, PyObject *arg)
{
PyObject *return_value = NULL;
int chr;

if (!PyArg_Parse(arg, "C:grapheme_cluster_break", &chr)) {
goto exit;
}
return_value = unicodedata_UCD_grapheme_cluster_break_impl(self, chr);

exit:
return return_value;
}

PyDoc_STRVAR(unicodedata_UCD_decomposition__doc__,
"decomposition($self, chr, /)\n"
"--\n"
Expand Down Expand Up @@ -379,4 +406,37 @@ unicodedata_UCD_lookup(PyObject *self, PyObject *arg)
exit:
return return_value;
}
/*[clinic end generated code: output=7ec9a3c8fbfd3c3a input=a9049054013a1b77]*/

PyDoc_STRVAR(unicodedata_UCD_iter_graphemes__doc__,
"iter_graphemes($self, unistr, start=0, end=sys.maxsize, /)\n"
"--\n"
"\n"
"Returns an iterator to iterate over grapheme clusters in unistr.\n"
"\n"
"It uses extended grapheme cluster rules from TR29.");

#define UNICODEDATA_UCD_ITER_GRAPHEMES_METHODDEF \
{"iter_graphemes", (PyCFunction)unicodedata_UCD_iter_graphemes, METH_FASTCALL, unicodedata_UCD_iter_graphemes__doc__},

static PyObject *
unicodedata_UCD_iter_graphemes_impl(PyObject *self, PyObject *unistr,
int start, Py_ssize_t end);

static PyObject *
unicodedata_UCD_iter_graphemes(PyObject *self, PyObject **args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyObject *unistr;
int start = 0;
Py_ssize_t end = PY_SSIZE_T_MAX - 1;

if (!_PyArg_ParseStack(args, nargs, "U|in:iter_graphemes",
&unistr, &start, &end)) {
goto exit;
}
return_value = unicodedata_UCD_iter_graphemes_impl(self, unistr, start, end);

exit:
return return_value;
}
/*[clinic end generated code: output=7d4b4e2561674e6e input=a9049054013a1b77]*/
Loading