wcswidth(3C)
wcswidth --
determine the number of column positions for a wide character string
Synopsis
   #include <wchar.h>
   
   int wcswidth(const wchar_t *pwcs, size_t n);
Description
wcswidth determines the number of column printing positions needed
for up to n wide characters in the wide string pwcs.
Fewer than n wide characters will be processed only if a null wide
character is encountered before n wide characters in pwcs.
Return values
wcswidth returns either zero if pwcs is pointing to a null wide
character code, or the number of column positions occupied by the wide character string
pointed to by pwcs.
wcswidth returns -1 if any wide character code in the wide character
string pointed to by pwcs is not a printable wide character.
Examples
This example function, when passed a wide character string, calculates
the number of column positions required and prints a diagnostic message.
   #include <wchar.h>
   #include <stdio.h>
   
   . . .
   
   int
   print_width(const wchar_t *pwcs)
   {
   	int width;
   	size_t len;
   
   	len = wcslen(pwcs);
   	if (len > 0)  {
   		width = wcswidth (pwcs, len);
   		if (width == -1)
   		   (void) printf("non printable character\n");
   		else
   		   (void) printf("Wide string width=%d\n",width);
   		return (1);
   	}
   
   	(void) printf("zero length wide character string\n");
   	return (0);
   
   }
References
wchar(5),
wcwidth(3C)
© 2004 The SCO Group, Inc.  All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004