handle 0-width surrogates.

This commit is contained in:
Christopher Jeffrey 2015-04-15 10:49:43 -07:00
parent cb363c575b
commit 62b1003a05
1 changed files with 4 additions and 1 deletions

View File

@ -2673,7 +2673,10 @@ main:
var surrogates = out[i].match(/[\ud800-\udbff][\udc00-\udfff]/g); var surrogates = out[i].match(/[\ud800-\udbff][\udc00-\udfff]/g);
if (surrogates && surrogates.length) { if (surrogates && surrogates.length) {
for (var j = 0; j < surrogates.length; j++) { for (var j = 0; j < surrogates.length; j++) {
if (east_asian_width.char_width(surrogates[j].codePointAt(0)) === 1) { var cwid = east_asian_width.char_width(surrogates[j].codePointAt(0));
if (cwid === 0) {
out[i] += ' ';
} else if (cwid === 1) {
out[i] += ' '; out[i] += ' ';
} }
} }