Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timoxley/wcwidth
Port of C's wcwidth() and wcswidth()
https://github.com/timoxley/wcwidth
Last synced: 4 days ago
JSON representation
Port of C's wcwidth() and wcswidth()
- Host: GitHub
- URL: https://github.com/timoxley/wcwidth
- Owner: timoxley
- License: other
- Created: 2014-05-11T23:46:00.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-02-03T17:40:23.000Z (almost 2 years ago)
- Last Synced: 2024-08-31T17:38:14.261Z (2 months ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 52
- Watchers: 4
- Forks: 9
- Open Issues: 4
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# wcwidth
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/)
## Example
```js
'한'.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](docs)
## License
MIT