From 987c92722565ad31742196be13edbab6eade1466 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 30 May 2020 05:56:48 +0200 Subject: [PATCH] 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 PR-URL: https://github.com/nodejs/node/pull/33650 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen --- lib/internal/util/inspect.js | 2 +- test/parallel/test-icu-stringwidth.js | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index a2405d77e0f966..4cb0ee55f080e7 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -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 diff --git a/test/parallel/test-icu-stringwidth.js b/test/parallel/test-icu-stringwidth.js index 4e8389961d0d6d..66142a8d6811c0 100644 --- a/test/parallel/test-icu-stringwidth.js +++ b/test/parallel/test-icu-stringwidth.js @@ -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);