util: improve unicode support

The array grouping function relies on the width of the characters.
It was not calculated correct so far, since it used the string
length instead.
This improves the unicode output by calculating the mono-spaced
font width (other fonts might differ).

PR-URL: https://github.com/nodejs/node/pull/31319
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Steven R Loomis <srloomis@us.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
This commit is contained in:
Ruben Bridgewater committed 2020-01-22 15:33:03 +01:00
1 parent 2606e1ed25
commit 8fb5fe28a4
11 files changed
+211 -192

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@ const {
ObjectPrototypeHasOwnProperty,
} = primordials;
const { getStringWidth } = require('internal/readline/utils');
const { getStringWidth } = require('internal/util/inspect');
// The use of Unicode characters below is the only non-comment use of non-ASCII
// Unicode characters in Node.js built-in modules. If they are ever removed or