Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/TopCli/wcwidth
Port of C's wcwidth() and wcswidth()
https://github.com/TopCli/wcwidth
cli stringlength stringwidth wcswidth wcwidth
Last synced: 23 days ago
JSON representation
Port of C's wcwidth() and wcswidth()
- Host: GitHub
- URL: https://github.com/TopCli/wcwidth
- Owner: TopCli
- License: other
- Fork: true (timoxley/wcwidth)
- Created: 2019-07-25T07:07:30.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-14T22:05:40.000Z (over 1 year ago)
- Last Synced: 2024-08-04T06:01:06.865Z (4 months ago)
- Topics: cli, stringlength, stringwidth, wcswidth, wcwidth
- Language: JavaScript
- Homepage:
- Size: 224 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-crafted-nodejs - @slimio/wcwidth - Fork of wcwidth. (Packages / CLI (TTY etc..))
README
# wcwidth
![version](https://img.shields.io/badge/dynamic/json.svg?style=for-the-badge&url=https://raw.githubusercontent.com/TopCli/wcwidth/master/package.json&query=$.version&label=Version)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg?style=for-the-badge)](https://github.com/TopCli/wcwidth/commit-activity)
[![mit](https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge)](https://github.com/TopCli/wcwidth/blob/master/LICENSE)
[![OpenSSF
Scorecard](https://api.securityscorecards.dev/projects/github.com/TopCli/wcwidth/badge?style=for-the-badge)](https://api.securityscorecards.dev/projects/github.com/TopCli/wcwidth)
![build](https://img.shields.io/github/actions/workflow/status/TopCli/wcwidth/node.js.yml?style=for-the-badge)Determine columns needed for a fixed-size wide-character string
> wcwidth is a simple JavaScript port of [wcwidth](http://man7.org/linux/man-pages/man3/wcswidth.3.html) implemented in C by Markus Kuhn.
>
> JavaScript port [originally](https://github.com/mycoboco/wcwidth.js) written by Woong Jun (http://code.woong.org/)## Why
This package is a fork of [wcwidth](https://github.com/timoxley/wcwidth#readme).
- Drop old Node.js version support.
- Drop useless `defaults` package wich introduce an indirect dependencies.
- Cleanup npm tarball (only ship required files).## Requirements
- [Node.js](https://nodejs.org/en/) v14 or higher## Getting Started
This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).
```bash
$ npm i @topcli/wcwidth
# or
$ yarn add @topcli/wcwidth
```## Usage example
```js
import wcwidth from "@topcli/wcwidth";'한'.length // => 1
wcwidth('한'); // => 2'한글'.length // => 2
wcwidth('한글'); // => 4
````wcwidth()` and its string version, `wcswidth()` are defined by IEEE Std
1002.1-2001, a.k.a. POSIX.1-2001, and return the number of columns used
to represent the given wide character and string.Markus's implementation assumes the wide character given to those
functions to be encoded in ISO 10646, which is almost true for
JavaScript's characters.[Further explaination here](https://github.com/timoxley/wcwidth/tree/master/docs)
## API
TBC## Contributors ✨
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Gentilhomme
💻 📖 👀 🛡️ 🐛
PierreDemailly
💻 🐛
## License
MIT