wcwidth() is a POSIX function that returns the number of cells that a wide-character occupies. The glibc function cannot be used as it depends on the locale and we need _always_ UTF8 no matter what the locale is. This implementation is provided by Markus Kuhn and is equivalent to xterm's behavior. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
19 lines
554 B
C
19 lines
554 B
C
/*
|
|
* This is an implementation of wcwidth() and wcswidth() (defined in
|
|
* IEEE Std 1002.1-2001) for Unicode.
|
|
*
|
|
* Markus Kuhn -- 2007-05-26 (Unicode 5.0)
|
|
*
|
|
* Permission to use, copy, modify, and distribute this software
|
|
* for any purpose and without fee is hereby granted. The author
|
|
* disclaims all warranties with regard to this software.
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
#include <wchar.h>
|
|
|
|
int mk_wcwidth(wchar_t ucs);
|
|
int mk_wcswidth(const wchar_t *pwcs, size_t n);
|
|
int mk_wcwidth_cjk(wchar_t ucs);
|
|
int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n);
|