util: fix width detection for DEL without ICU

This makes sure the DEL character (ASCII 127) is detected as a zero
width character even if Node.js is not built with ICU.

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

PR-URL: https://github.com/nodejs/node/pull/33650
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
Ruben Bridgewater authored and Shelley Vohr committed 2020-07-14 12:13:28 -07:00
1 parent 9d9c15a5c3
commit 677dce13e7
2 files changed
+2 -5

No files matched your search

+1 -1
View File
@@ -2047,7 +2047,7 @@ if (internalBinding('config').hasIntl) {
const isZeroWidthCodePoint = (code) => {
return code <= 0x1F || // C0 control codes
(code > 0x7F && code <= 0x9F) || // C1 control codes
(code >= 0x7F && code <= 0x9F) || // C1 control codes
(code >= 0x300 && code <= 0x36F) || // Combining Diacritical Marks
(code >= 0x200B && code <= 0x200F) || // Modifying Invisible Characters
// Combining Diacritical Marks for Symbols
+1 -4
View File
@@ -2,9 +2,6 @@
'use strict';
const common = require('../common');
if (!common.hasIntl)
common.skip('missing Intl');
const assert = require('assert');
const { getStringWidth } = require('internal/util/inspect');
@@ -88,7 +85,7 @@ for (let i = 0; i < 256; i++) {
}
}
{
if (common.hasIntl) {
const a = '한글'.normalize('NFD'); // 한글
const b = '한글'.normalize('NFC'); // 한글
assert.strictEqual(a.length, 6);