#include <wchar.h>
|
int
wcwidth (wchar_t wc); |
The behavior of the wcwdith is affected by LC_CTYPE category of the current locale.
#include <wchar.h> /* Illustrates how to use wcwidth API */ int example_wcwidth() { /* wide character for which width has to be determined */ wchar_t wc = L’a’; int retval; /* determine the width of wc */ retval = wcwidth(wc); /* return the determined width */ return retval; }
wint_t ch; int column, w; column = 0; while ((ch = getwchar()) != WEOF) { w = wcwidth(ch); if (w > 0 && column + w >= 20) { putwchar(L’ \en’); column = 0; } putwchar(ch); if (ch == L’ \en’) column = 0; else if (w > 0) column += w; }
© 2005-2007 Nokia |