DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

wcwidth(S)


wcwidth -- determine the number of column positions for a wide character

Synopsis

#include <wchar.h>

int wcwidth(wint_t wc);

Description

wcwidth determines the number of column printing positions that are needed by the wide character wc.

Return values

wcwidth returns zero if wc is a null wide character, or the number of column printing positions the wide character wc occupies. wcwidth returns -1 if wc does not correspond to a valid, printable wide character.

Example

Here is a program that reads a wide character from standard input and prints the width of the character.

#include <wchar.h>
#include <stdio.h>

main()
{
int x;
wint_t wc;

if ((wc=fgetwc(stdin)) != WEOF) {
x=wcwidth(wc);
if (x==-1)
(void) printf("Character not printable\n");
else
(void) printf("Character width=%d\n",x);
exit(0);
}
(void) printf("Error encountered reading character\n");
exit(2);
}

References

wchar(M), wcswidth(S)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005