Guardian Native C Library Calls Reference Manual (G06.28+, H06.05+)

wcswidth(3) Guardian Native C Library Calls Reference Manual
NAME
wcswidth - Determines the display width of wide-character strings
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZCRTLSRL
G-series native OSS processes: /G/system/sysnn/zcrtlsrl
H-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
H-series OSS processes: /G/system/zdllnnn/zcrtldll
SYNOPSIS
#include <wchar.h>
int wcswidth(
wchar_t *pwcs,
size_t n);
PARAMETERS
n Species the maximum number of wide characters whose display width is to be
determined.
pwcs Contains a pointer to the wide-character string.
DESCRIPTION
The wcswidth() function determines the number of display columns to be occupied by the
number of wide characters specied by the n parameter in the string pointed to by the pwcs
parameter. The behavior of the wcswidth() function is affected by the LC_CTYPE category.
Fewer than the number of wide characters specied by the n parameter are counted if a NULL
character is encountered rst.
EXAMPLES
The following example nds the display column width of a wide-character string.
#include <wchar.h>
#include <locale.h>
main()
{
wchar_t *pwcs;
int retval, n ;
(void)setlocale(LC_ALL, "");
/* Let pwcs point to a wide-character null terminated
** string. Let n be the number of wide characters whose
** display column width is to be determined.
*/
retval= wcswidth( pwcs, n );
if(retval == -1){
/* Error handling. Invalid wide character code
** encountered in the wide character string pwcs.
*/
}
}
RETURN VALUES
The wcswidth() function returns the number of display columns to be occupied by the number of
wide characters (up to the terminating null wide character specied by the n parameter (or fewer)
in the string pointed to by the pwcs parameter. A value of 0 (zero) is returned if the pwcs param-
eter is a wide-character NULL pointer or a pointer to a wide-character NULL pointer (that is,
pwcs or *pwcs is NULL). If the pwcs parameter points to an unusable wide character code, a
790 Hewlett-Packard Company 527192-007