0.1.0 • Published 6 years ago
unicode-string-width v0.1.0
unicode-string-width
Get the visual width of a unicode string - the number of columns required to display it
Handles:
- fullwidth characters
- ANSI escape codes escape codes (terminal corols)
- ASCII control characters
- additional variation selector characters in iOS/OSX
Install
$ npm install unicode-string-width
Usage
const unicodeStringWidth = require('unicode-string-width');
unicodeStringWidth('古');
//=> 2
unicodeStringWidth('\u001b[1mဤဥဩဪါ\u001b[22m');
//=> 5
unicodeStringWidth('a');
//=> 1
License
- Unlicense (~Public Domain)
Related Work
- string-width - Same stuff, just with a bug. I should have probably just make a PR with a bug fix, but by the time I understood what the bug was, I had this fully functional :)
0.1.0
6 years ago