Skip to content

Commit

Permalink
util: fix width detection for DEL without ICU
Browse files Browse the repository at this point in the history
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]>

PR-URL: #33650
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
BridgeAR authored and codebytere committed Jun 27, 2020
1 parent 91d0d53 commit 987c927
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2056,7 +2056,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
Expand Down
5 changes: 1 addition & 4 deletions test/parallel/test-icu-stringwidth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 987c927

Please sign in to comment.