Handle surrogate utf16 characters

For our own sanity we (falsely) assume that all surrogate characters are
double width, otherwise we have to go back and reflow the line.

This makes it work better with emojis in vim at least.

REVIEW: 129841
wilder-portage
Martin T. H. Sandsmark 9 years ago
parent cd61ee84d8
commit 1c13e4841d
  1. 2
      src/Screen.cpp
  2. 8
      src/konsole_wcwidth.cpp

@ -636,7 +636,7 @@ void Screen::displayCharacter(unsigned short c)
return;
} else if (w == 0) {
const QChar::Category category = QChar(c).category();
if (category != QChar::Mark_NonSpacing && category != QChar::Letter_Other) {
if (category != QChar::Mark_NonSpacing && category != QChar::Letter_Other && !QChar::isLowSurrogate(c)) {
return;
}
// Find previous "real character" to try to combine with

@ -186,8 +186,14 @@ int KONSOLEPRIVATE_EXPORT konsole_wcwidth(quint16 oucs)
};
/* test for 8-bit control characters */
if (ucs == 0)
if (ucs == 0 || QChar::isLowSurrogate(ucs))
return 0;
/* Always assume double width, otherwise we have to go back and move characters */
if (QChar::isHighSurrogate(ucs)) {
return 2;
}
if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0))
return -1;

Loading…
Cancel
Save