Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Jun 1, 2024 via pnpm

wcwidth 1.0.1

Port of C's wcwidth() and wcswidth()
Package summary
Share
0
issues
1
license
3
MIT
Package created
27 Jul 2014
Version published
30 May 2016
Maintainers
1
Total deps
3
Direct deps
1
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
3 Packages, Including:
clone@1.0.4
defaults@1.0.4
wcwidth@1.0.1
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

1
All Dependencies CSV
ⓘ This is a list of wcwidth 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
defaults1.0.41.93 kBMIT
prod

Visualizations

Frequently Asked Questions

What does wcwidth do?

wcwidth is a JavaScript port of the C function wcwidth, originally penned by Markus Kuhn and later adapted to JavaScript by Woong Jun. This tool's main utility lies in determining the number of columns needed to accurately represent a fixed-sized, wide-character string. This is particularly helpful when a program must ascertain how much space a string will require when it is displayed. wcwidth returns the required number of columns, taking into consideration characters that are of varying widths, such as particular Unicode characters. For instance, certain East Asian wide characters may require twice the width of a standard ASCII character. The wcwidth function essentially accounts for these variances and returns the proper column count.

How do you use wcwidth?

The use of wcwidth is relatively straightforward. You simply call the function, passing the string for which you want to determine the column width as the argument. The function will return the number of columns required to properly represent the string. Below is an example of how to use the wcwidth function:

var wcwidth = require('wcwidth');

console.log('한'.length);        // Outputs: 1
console.log(wcwidth('한'));   // Outputs: 2

console.log('한글'.length);      // Outputs: 2
console.log(wcwidth('한글')); // Outputs: 4

In this example, although the Korean characters '한' and '한글' have lengths of 1 and 2 respectively (when counted as JavaScript string lengths), they require 2 and 4 columns respectively when considered from a display width perspective. This discrepancy is what wcwidth manages to address effectively.

Where are the wcwidth docs?

The documentation for wcwidth can be accessed directly from this package's repository. To learn more about this function, its implementation and potential use cases, you may refer to the wcwidth documentation. This comprehensive guide provides further explanation and completes the information to understand this valuable tool in detail.

All Versions