Last change
on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
887 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | # wcwidth
|
---|
| 2 |
|
---|
| 3 | Determine columns needed for a fixed-size wide-character string
|
---|
| 4 |
|
---|
| 5 | ----
|
---|
| 6 |
|
---|
| 7 | wcwidth is a simple JavaScript port of [wcwidth](http://man7.org/linux/man-pages/man3/wcswidth.3.html) implemented in C by Markus Kuhn.
|
---|
| 8 |
|
---|
| 9 | JavaScript port [originally](https://github.com/mycoboco/wcwidth.js) written by Woong Jun <woong.jun@gmail.com> (http://code.woong.org/)
|
---|
| 10 |
|
---|
| 11 | ## Example
|
---|
| 12 |
|
---|
| 13 | ```js
|
---|
| 14 | '한'.length // => 1
|
---|
| 15 | wcwidth('한'); // => 2
|
---|
| 16 |
|
---|
| 17 | '한글'.length // => 2
|
---|
| 18 | wcwidth('한글'); // => 4
|
---|
| 19 | ```
|
---|
| 20 |
|
---|
| 21 | `wcwidth()` and its string version, `wcswidth()` are defined by IEEE Std
|
---|
| 22 | 1002.1-2001, a.k.a. POSIX.1-2001, and return the number of columns used
|
---|
| 23 | to represent the given wide character and string.
|
---|
| 24 |
|
---|
| 25 | Markus's implementation assumes the wide character given to those
|
---|
| 26 | functions to be encoded in ISO 10646, which is almost true for
|
---|
| 27 | JavaScript's characters.
|
---|
| 28 |
|
---|
| 29 | [Further explaination here](docs)
|
---|
| 30 |
|
---|
| 31 | ## License
|
---|
| 32 |
|
---|
| 33 | MIT
|
---|
Note:
See
TracBrowser
for help on using the repository browser.