wcwidth(3C) wcwidth(3C)
NAME
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)
Copyright 1994 Novell, Inc. Page 1