a javascript porting of C's wcwidth()