wcwidth(3C)


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(5), wcswidth(3C)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004