Platform independent, header only, wcwidth with full unicode 9 support; Joshua Rubin (2016).
npm install wcwidth9.cwcwidth9.h in your project and use the wcwidth9 function.
wcwidth.
c
int wcwidth9(int c);
`
The input value c is expected to be a unicode code point value. The widths returned are according to unicode version 9.0.0.
Return values:
* 1 or 2: the width of the character
* -1: non-printable, combining or unassigned character
* -2: ambiguous width character
* -3: private-use character
Ambiguous width characters should almost always be considered width 1 except in the context of some East Asian languages as described here.
As private-use characters may not necessarily need to vary depending on East Asian context, but are still considered ambiguous, a separate return value is provided to distinguish them.
Installation
Run:
`sh
$ npm i wcwidth9.c
`
And then include wcwidth9.h as follows:
`c
// main.c
#include
int main() { / ... / }
`
Finally, compile while adding the path node_modules/wcwidth9.c to your compiler's include paths.
`bash
$ clang -I./node_modules/wcwidth9.c main.c # or, use gcc
$ gcc -I./node_modules/wcwidth9.c main.c
`
You may also use a simpler approach with the cpoach tool, which automatically adds the necessary include paths of all the installed dependencies for your project.
`bash
$ cpoach clang main.c # or, use gcc
$ cpoach gcc main.c
``