Skip to content

Commit afc46f7

Browse files
committed
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 <[email protected]>
1 parent 03f76d5 commit afc46f7

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

lib/internal/util/inspect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2054,7 +2054,7 @@ if (internalBinding('config').hasIntl) {
20542054

20552055
const isZeroWidthCodePoint = (code) => {
20562056
return code <= 0x1F || // C0 control codes
2057-
(code > 0x7F && code <= 0x9F) || // C1 control codes
2057+
(code >= 0x7F && code <= 0x9F) || // C1 control codes
20582058
(code >= 0x300 && code <= 0x36F) || // Combining Diacritical Marks
20592059
(code >= 0x200B && code <= 0x200F) || // Modifying Invisible Characters
20602060
// Combining Diacritical Marks for Symbols

test/parallel/test-icu-stringwidth.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
'use strict';
33
const common = require('../common');
44

5-
if (!common.hasIntl)
6-
common.skip('missing Intl');
7-
85
const assert = require('assert');
96
const { getStringWidth } = require('internal/util/inspect');
107

@@ -88,7 +85,7 @@ for (let i = 0; i < 256; i++) {
8885
}
8986
}
9087

91-
{
88+
if (common.hasIntl) {
9289
const a = '한글'.normalize('NFD'); // 한글
9390
const b = '한글'.normalize('NFC'); // 한글
9491
assert.strictEqual(a.length, 6);

0 commit comments

Comments
 (0)