Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

wcswidth(3) [osf1 man page]

wcswidth(3)						     Library Functions Manual						       wcswidth(3)

NAME
wcswidth - Determines the display width of wide-character strings LIBRARY
Standard C Library (libc) SYNOPSIS
#include <wchar.h> int wcswidth( const wchar_t *pwcs, size_t n); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: wcswidth(): XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Contains a pointer to the wide-character string. Specifies the maximum number of wide characters whose display width is to be determined. DESCRIPTION
The wcswidth() function determines the number of display columns to be occupied by the number of wide characters specified by the n parame- ter 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 specified by the n parameter are counted if a null wide character is encountered first. EXAMPLES
The following example finds 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 specified number of wide characters or (if a null wide character is encountered first) by the number of wide characters encountered before the null. The function returns a value of 0 (zero) if the pwcs parameter is a null pointer or a pointer to a null pointer (that is, if either pwcs or *pwcs is null. The function returns -1 if the pwcs parameter points to a nonprinting wide character. RELATED INFORMATION
Functions: mblen(3), wcslen(3), wcwidth(3) Standards: standards(5) delim off wcswidth(3)

Check Out this Related Man Page

mbstowcs(3)						     Library Functions Manual						       mbstowcs(3)

NAME
mbstowcs, mbsrtowcs - Converts a multibyte character string to a wide-character string LIBRARY
Standard C Library (libc) SYNOPSIS
#include <stdlib.h> size_t mbstowcs( wchar_t *pwcs, const char *s, size_t n); #include <wchar.h> size_t mbsrtowcs( wchar_t *pwcs, const char **s, size_t n, mbstate_t *ps ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: mbstowcs(), mbsrtowcs(): XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Points to the array where the result of the conversion is stored. Points or indirectly points to the multibyte-character string to be con- verted. Specifies the number of wide characters in the destination array. Points to an mbstate_t structure containing the conversion state of the data in s. DESCRIPTION
The mbstowcs() function converts a multibyte-character string into a wide-character string, which is stored at a specified location. The function does not examine or convert any characters that follow a null byte, which is converted and stored as a wide-character code with value zero. The function does not store more than n wide characters in pwcs. When operating on overlapping strings, the behavior of this function is undefined. Behavior of the mbstowcs() function is affected by the LC_CTYPE category of the current locale. In locales that use shift-state encoding, the array pointed to by the s parameter begins in the initial shift state. The mbsrtowcs() function is a restartable version of mbstowcs(). Restartable conversion functions obtain and store the conversion state in an mbstate_t structure that can be read and changed by subsequent calls to the same or other restartable conversion functions. RESTRICTIONS
[Tru64 UNIX] The mbsrtowcs() and other restartable versions of conversion functions are functional only when used with locales that sup- port shift-state encoding. Currently, the operating system does not provide any locales that support shift-state encoding, so the mbstowcs() and mbsrtowcs() functions do not differ in terms of run-time behavior. RETURN VALUES
When the mbstowcs() and mbsrtowcs() functions encounter an invalid multibyte character during conversion, they return a value of -1 cast to size_t and set errno to indicate the error. Otherwise: The mbstowcs() function returns the number of characters stored in the output array (or required if pwcs is null), not including a terminating null wide character, if any. When the return value is n, the output array is not null-terminated. The mbsrtowcs() function returns the number of characters stored in the output array, not including a terminating null wide character, if any. ERRORS
If the following condition occurs, the mbstowcs() and mbsrtowcs() functions set errno to the corresponding value: The s parameter contains an invalid multibyte character. RELATED INFORMATION
Functions: btowc(3), mblen(3), mbsinit(3), mbtowc(3), wcstombs(3), wcslen(3), wctob(3), wctomb(3) delim off mbstowcs(3)
Man Page