Add support for Vs-15 to wcswidth

This commit is contained in:
Kovid Goyal 2019-05-13 19:50:49 +05:30
parent 4fff84b4b9
commit fe882dad15
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 0 deletions

View File

@ -1734,6 +1734,11 @@ screen_wcswidth(PyObject UNUSED *self, PyObject *str) {
ans += 1;
prev_width = 2;
} else prev_width = 0;
} else if (ch == 0xfe0e) {
if (is_emoji_presentation_base(prev_ch) && prev_width == 2) {
ans -= 1;
prev_width = 1;
} else prev_width = 0;
} else {
int w = wcwidth_std(ch);
switch(w) {

View File

@ -344,6 +344,8 @@ class TestDataTypes(BaseTest):
self.ae(tuple(map(w, 'a1\0コニチ ✔')), (1, 1, 0, 2, 2, 2, 1, 1))
self.ae(wcswidth('\u2716\u2716\ufe0f\U0001f337'), 5)
self.ae(wcswidth('\033a\033[2mb'), 2)
self.ae(wcswidth('\u25b6\ufe0f'), 2)
self.ae(wcswidth('\U0001f610\ufe0e'), 1)
# Regional indicator symbols (unicode flags) are defined as having
# Emoji_Presentation so must have width 2
self.ae(tuple(map(w, '\U0001f1ee\U0001f1f3')), (2, 2))