Format
#include <wchar.h> int wcwidth (const wint_t wc);
Language Level: XPG4
Threadsafe: Yes.
Description
The wcwidth() function determines the number of printing positions that a graphic representation of wc occupies on a display device. Each of the printing wide characters occupies its own number of printing positions 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 wcwidth() function either returns:
The behavior of the wcwidth() function is affected by the LC_CTYPE category of the current locale. 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 wcwidth()
#include <stdio.h> #include <wchar.h> int main(void) { wint_t wc = L'A'; printf("%lc has a width of %d\n", wc, wcwidth(wc)); return 0; /************************************************************************** The output should be similar to : A has a width of 1 **************************************************************************/ }
Related Information
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.