Format
#include <wchar.h> int wcswidth (const wchar_t *wcs, size_t n);
Language Level: XPG4
Threadsafe: Yes.
Description
The wcswidth() function determines the number of printing positions that a graphic representation of n wide characters (or fewer that n wide characters if a null wide character is encountered before n wide characters have been exhausted) in the wide string pointed to by wcs occupies on a display device. The number is independent of its location on the device.
The value of errno may be set to EINVAL (non-printing wide character).
Return Value
The wcswidth() function either returns:
The behavior of the wcswidth() function is affected by the LC_CTYPE category. If the program is compiled with a UNICODE LOCALETYPE, the wide character properties are those defined by the LC_UNI_CTYPE category of the current locale.
Example that uses wcswidth()
#include <stdio.h> #include <wchar.h> int main(void) { wchar_t *wcs = L"ABC"; printf("wcs has a width of: %d\n", wcswidth(wcs,3)); } /************The output is as follows**************/ /* */ /* wcs has a width of: 3 */ /* */ /**********************************************/
Related Information
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.