[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 2

wcwidth Subroutine

Purpose

Determines the display width of wide characters.

Library

Standard C Library (libc.a)

Syntax

#include <string.h>
int wcwidth (WC)
wchar_t WC;

Description

The wcwidth subroutine determines the number of display columns to be occupied by the wide character specified by the WC parameter. The LC_CTYPE subroutine affects the behavior of the wcwidth subroutine.

Parameters

WC Specifies a wide character.

Return Values

The wcwidth subroutine returns the number of display columns to be occupied by the WC parameter. If the WC parameter is a wide character null, a value of 0 is returned. If the WC parameter points to an unusable wide character code, -1 is returned.

Examples

To find the display column width of a wide character, use the following:

#include <string.h>
#include <locale.h>
#include <stdlib.h>
 
main()
{
   wchar_t wc;
   int   retval;
 
   (void)setlocale(LC_ALL, "");
   /* Let wc be the wide character whose
   ** display width is to be found.
   */
   retval= wcwidth( wc );
   if(retval == -1){
            /* 
            ** Error handling. Invalid wide character in wc.
            */
   }
}

Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Related Information

The wcswidth subroutine.

National Language Support Overview for Programming, Subroutines Overview, Understanding Wide Character Display Column Width Subroutines in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.


[ Previous | Next | Contents | Glossary | Home | Search ]