You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
887 B

3 months ago
  1. # wcwidth
  2. Determine columns needed for a fixed-size wide-character string
  3. ----
  4. wcwidth is a simple JavaScript port of [wcwidth](http://man7.org/linux/man-pages/man3/wcswidth.3.html) implemented in C by Markus Kuhn.
  5. JavaScript port [originally](https://github.com/mycoboco/wcwidth.js) written by Woong Jun <woong.jun@gmail.com> (http://code.woong.org/)
  6. ## Example
  7. ```js
  8. '한'.length // => 1
  9. wcwidth('한'); // => 2
  10. '한글'.length // => 2
  11. wcwidth('한글'); // => 4
  12. ```
  13. `wcwidth()` and its string version, `wcswidth()` are defined by IEEE Std
  14. 1002.1-2001, a.k.a. POSIX.1-2001, and return the number of columns used
  15. to represent the given wide character and string.
  16. Markus's implementation assumes the wide character given to those
  17. functions to be encoded in ISO 10646, which is almost true for
  18. JavaScript's characters.
  19. [Further explaination here](docs)
  20. ## License
  21. MIT