mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-25 17:52:02 +02:00
Add a wcswidth() implementation useable from C code
This commit is contained in:
@@ -118,6 +118,15 @@ wcswidth_step(WCSState *state, const char_type ch) {
|
||||
return ans;
|
||||
}
|
||||
|
||||
size_t
|
||||
wcswidth_string(const char_type *s) {
|
||||
WCSState state;
|
||||
initialize_wcs_state(&state);
|
||||
size_t ans = 0;
|
||||
while (*s) ans += wcswidth_step(&state, *(s++));
|
||||
return ans;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
wcswidth_std(PyObject UNUSED *self, PyObject *str) {
|
||||
if (PyUnicode_READY(str) != 0) return NULL;
|
||||
|
||||
Reference in New Issue
Block a user