
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
wcwidth-o1
Advanced tools
A TypeScript/JavaScript implementation of glibc’s wcwidth(3) and wcswidth(3), optimized to O(1).
Conforms to POSIX.1-2008 (IEEE Std 1003.1) for
terminal column width calculation.
Install Wcwidth-O1 via npm:
npm i wcwidth-o1
import wcwidth from 'wcwidth-o1';
const example1 = wcwidth('a'); // 1
const example2 = wcwidth('好'); // 2
const example3 = wcwidth('😊'); // 2
or
import { wcwidth, wcswidth } from 'wcwidth-o1';
const example = wcwidth('a'); // 1
const example1 = wcswidth('hi'); // 2
const example2 = wcswidth('안녕하세요'); // 10
const example3 = wcswidth('😊こんにちは'); // 12
wcwidth():
char: A single-character string to measure.wcswidth():
str: Input string to evaluate.n: Max characters to process (defaults to full length).When a new Unicode version is released, the lookup table must be regenerated to follow the latest character width definitions.
./genTable.sh
If your environment is not glibc-based, you'll see:
[ WARNING ] Please compile on a glibc-based Linux distro (e.g. Debian).
Once the generation is complete, you should see:
[ SUCCESS ] table.ts generated successfully.
Copy the generated table.ts into src/:
cp table.ts src/
The lookup table update is then complete.
In fixed-width terminals, most Latin characters take up one column, while East Asian (CJK) ideographs usually take up two. The challenge is deciding how many “cells” each Unicode character should occupy so that text aligns correctly.
The Unicode standard defines width classes:
Other rules include:
U+0000 (null) - width 0-1U+00AD) - width 1U+200B) - width 0This logic originates from Markus Kuhn’s reference implementation and is widely used in terminal emulators to ensure consistent alignment.
See Unicode TR#11 for more details.
Found something odd?
Feel free to open an issue.
wcwidth and wcswidth specifications defined by POSIX.1-2008 (IEEE Std 1003.1).Distributed under the MIT License.
See LICENSE for more information.
FAQs
glibc wcwidth/wcswidth for Node.js & TypeScript.
We found that wcwidth-o1 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.