Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ wcswidth(3C) — UnixWare 2.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

wchar(5)

wcwidth(3C)






       wcswidth(3C)                                            wcswidth(3C)


       NAME
             wcswidth - determine the number of column positions for a wide
             character string

       SYNOPSIS
             #include <wchar.h>
             int wcswidth(const wchar_t *pwcs, size_t n);

       DESCRIPTION
             wcswidth determines the number of column printing positions
             needed for up to n wide characters in the wide string pwcs.
             Fewer than n wide characters will be processed only if a null
             wide character is encountered before n wide characters in
             pwcs.

          Return Values
             wcswidth returns either zero if pwcs is pointing to a null
             wide character code, or the number of column positions
             occupied by the wide character string pointed to by pwcs.
             wcswidth returns -1 if any wide character code in the wide
             character string pointed to by pwcs is not a printable wide
             character.

       EXAMPLES
             This example function, when passed a wide character string,
             calculates the number of column positions required and prints
             a diagnostic message.

                   #include <wchar.h>
                   #include <stdio.h>
                   . . .
                   int
                   print_width(const wchar_t *pwcs)
                   {
                         int width;
                         size_t len;
                         len = wcslen(pwcs);
                         if (len > 0)  {
                               width = wcswidth (pwcs, len);
                               if (width == -1)
                                  (void) printf("non printable character\n");
                               else
                                  (void) printf("Wide string width=%d\n",width);
                               return (1);
                         }
                         (void) printf("zero length wide character string\n");


                           Copyright 1994 Novell, Inc.               Page 1













      wcswidth(3C)                                            wcswidth(3C)


                        return (0);

                  }

      REFERENCES
            wchar(5), wcwidth(3C)










































                          Copyright 1994 Novell, Inc.               Page 2








Typewritten Software • bear@typewritten.org • Edmonds, WA 98026