Port of C's wcwidth() and wcswidth()