[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP C
Run-Time Library Reference Manual for OpenVMS Systems


Previous Contents Index


wctob

Determines if a wide character corresponds to a single-byte multibyte character and returns its multibyte character representation.

Format

#include <stdio.h>

#include <wchar.h>

int wctob (wint_t c);


Argument

c

The wide character to be converted to a single-byte multibyte character.

Description

The wctob function determines whether the specified wide character corresponds to a single-byte multibyte character when in the initial shift state and, if so, returns its multibyte character representation.

Return Values

x The single-byte representation of the wide character specified.
EOF Indicates an error. The wide character specified does not correspond to a single-byte multibyte character.

wctomb

Converts a wide character to its multibyte character representation.

Format

#include <stdlib.h>

int wctomb (char *s, wchar_t wchar);


Arguments

s

A pointer to the resulting multibyte character.

wchar

The code for the wide character.

Description

The wctomb function converts the wide character specified by wchar to its multibyte character representation. If s is NULL, then 0 is returned. Otherwise, the number of bytes comprising the multibyte character is returned. At most, MB_CUR_MAX bytes are stored in the array object pointed to by s.

This function is affected by the LC_CTYPE category of the program's current locale.


Return Values

x The number of bytes comprising the multibyte character corresponding to wchar.
0 If s is NULL.
- 1 If wchar is not a valid character.

wctrans

Returns the description of a mapping, corresponding to specified property, that can later be used in a call to towctrans .

Format

#include <wctype.h>

wctrans_t wctrans (const char *property);


Argument

property

The name of the mapping. The following property names are defined for all locales:
  • "toupper"
  • "tolower"

Additional property names may also be defined in the LC_CTYPE category of the current locale.


Description

The wctrans function constructs a value with type wctrans_t that describes a mapping between wide characters identified by the property argument.

See also towctrans .


Return Values

nonzero According to the LC_CTYPE category of the current program locale, the string specified as a property argument is the name of an existing character mapping. The value returned can be used in a call to the towctrans function.
0 Indicates an error. The property argument does not identify a character mapping in the current program's locale.

wctype

Used for defining a character class. The value returned by this function is used in calls to the iswctype function.

Format

#include <wctype.h> (ISO C)

#include <wchar.h> (XPG4)

wctype_t wctype (const char *char_class);


Argument

char_class

A pointer to a valid character class name.

Description

The wctype function converts a valid character class defined for the current locale to an object of type wctype_t . The following character class names are defined for all locales:


alnum        cntrl        lower        space
alpha        digit        print        upper
blank        graph        punct        xdigit

Additional character class names may also be defined in the LC_CTYPE category of the current locale.

See also iswctype .


Return Values

x An object of type wctype_t that can be used in calls to the iswctype function.
0 If the character class name is not valid for the current locale.

Example


#include <locale.h>
#include <wchar.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>


 /* This test will set up a number of character class using wctype() */
 /* and then verify whether calls to iswctype() using these classes  */
 /* produce the same results as calls to the is**** routines.        */

main()
{

    wchar_t w_char;
    wctype_t ret_val;

    char *character = "A";

    /* Convert character to wide character format - w_char */

    if (mbtowc(&w_char, character, 1) == -1) {
        perror("mbtowc");
        exit(EXIT_FAILURE);
    }

    /* Check if results from iswalnum() matches check on */
    /* alnum character class                             */

    if ((iswalnum((wint_t) w_char)) &&
        (iswctype((wint_t) w_char, wctype("alnum"))))
        printf("[%C] is a member of the character class alnum\n", w_char);
 else
    printf("[%C] is not a member of the character class alnum\n", w_char);

    /* Check if results from iswalpha() matches check on */
    /* alpha character class                             */

    if ((iswalpha((wint_t) w_char)) &&
        (iswctype((wint_t) w_char, wctype("alpha"))))
      printf("[%C] is a member of the character class alpha\n", w_char);
    else
     printf("[%C] is not a member of the character class alpha\n", w_char);

    /* Check if results from iswcntrl() matches check on */
    /* cntrl character class                             */

    if ((iswcntrl((wint_t) w_char)) &&
        (iswctype((wint_t) w_char, wctype("cntrl"))))
        printf("[%C] is a member of the character class cntrl\n", w_char);
    else
     printf("[%C] is not a member of the character class cntrl\n", w_char);

    /* Check if results from iswdigit() matches check on */
    /* digit character class                             */

    if ((iswdigit((wint_t) w_char)) &&
        (iswctype((wint_t) w_char, wctype("digit"))))
        printf("[%C] is a member of the character class digit\n", w_char);
    else
     printf("[%C] is not a member of the character class digit\n", w_char);

    /* Check if results from iswgraph() matches check on */
    /* graph character class                             */

    if ((iswgraph((wint_t) w_char)) &&
        (iswctype((wint_t) w_char, wctype("graph"))))
        printf("[%C] is a member of the character class graph\n", w_char);
    else
     printf("[%C] is not a member of the character class graph\n", w_char);

    /* Check if results from iswlower() matches check on */
    /* lower character class                             */

    if ((iswlower((wint_t) w_char)) &&
        (iswctype((wint_t) w_char, wctype("lower"))))
        printf("[%C] is a member of the character class lower\n", w_char);
    else
     printf("[%C] is not a member of the character class lower\n", w_char);

    /* Check if results from iswprint() matches check on */
    /* print character class                             */

    if ((iswprint((wint_t) w_char)) &&
        (iswctype((wint_t) w_char, wctype("print"))))
        printf("[%C] is a member of the character class print\n", w_char);
    else
     printf("[%C] is not a member of the character class print\n", w_char);

    /* Check if results from iswpunct() matches check on */
    /* punct character class                             */

    if ((iswpunct((wint_t) w_char)) &&
        (iswctype((wint_t) w_char, wctype("punct"))))
        printf("[%C] is a member of the character class punct\n", w_char);
    else
     printf("[%C] is not a member of the character class punct\n", w_char);

    /* Check if results from iswspace() matches check on */
    /* space character class                             */

    if ((iswspace((wint_t) w_char)) &&
        (iswctype((wint_t) w_char, wctype("space"))))
        printf("[%C] is a member of the character class space\n", w_char);
    else
    printf("[%C] is not a member of the character class space\n", w_char);

    /* Check if results from iswupper() matches check on */
    /* upper character class                             */

    if ((iswupper((wint_t) w_char)) &&
        (iswctype((wint_t) w_char, wctype("upper"))))
        printf("[%C] is a member of the character class upper\n", w_char);
    else
    printf("[%C] is not a member of the character class upper\n", w_char);

    /* Check if results from iswxdigit() matches check on */
    /* xdigit character class                             */

    if ((iswxdigit((wint_t) w_char)) &&
        (iswctype((wint_t) w_char, wctype("xdigit"))))
        printf("[%C] is a member of the character class xdigit\n", w_char);
    else
     printf("[%C] is not a member of the character class xdigit\n", w_char);

}

Running this example produces the following result:


[A] is a member of the character class alnum
[A] is a member of the character class alpha
[A] is not a member of the character class cntrl
[A] is not a member of the character class digit
[A] is a member of the character class graph
[A] is not a member of the character class lower
[A] is a member of the character class print
[A] is not a member of the character class punct
[A] is not a member of the character class space
[A] is a member of the character class upper
[A] is a member of the character class xdigit

wcwidth

Determines the number of printing positions on a display device required for the specified wide character.

Format

#include <wchar.h>

int wcwidth (wchar_t wc);


Argument

wc

A wide character.

Description

The wcwidth function determines the number of column positions needed for the specified wide character wc. The value of wc must be a valid wide character in the current locale.

Return Values

x The number of printing positions required for wc.
0 If wc is a null character.
- 1 Indicates that wc does not represent a valid printing wide character.

wmemchr

Locates the first occurrence of a specified wide character in an array of wide characters.

Format

#include <wchar.h>

wchar_t wmemchr (const wchar_t *s, wchar_t c, size_t n);

Function Variants The wmemchr function has variants named _wmemchr32 and _wmemchr64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.10 for more information on using pointer-size-specific functions.

Arguments

s

A pointer to an array of wide characters to be searched.

c

The wide character value to search for.

n

The maximum number of wide characters in the array to be searched.

Description

The wmemchr function locates the first occurrence of the specified wide character in the initial n wide characters of the array pointed to by s.

Return Values

x A pointer to the first occurrence of the wide character in the array.
NULL The specified wide character does not occur in the array.

wmemcmp

Compares two arrays of wide characters.

Format

#include <wchar.h>

int wmemcmp (const wchar_t *s1, const wchar_t *s2, size_t n);


Arguments

s1, s2

Pointers to wide-character arrays.

n

The maximum number of wide characters to be compared.

Description

The wmemcmp function compares the first n wide characters of the array pointed to by s1 with the first n wide characters of the array pointed to by s2. The wide characters are compared not according to locale-dependent collation rules, but as integral objects of type wchar_t .

Return Values

0 Arrays are equal.
Positive value The first array is greater than the second.
Negative value The first array is less than the second.

wmemcpy

Copies a specified number of wide characters from one wide-character array to another.

Format

#include <wchar.h>

wchar_t wmemcpy (wchar_t *dest, const wchar_t *source, size_t n);

Function Variants The wmemcpy function has variants named _wmemcpy32 and _wmemcpy64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.10 for more information on using pointer-size-specific functions.

Arguments

dest

A pointer to the destination array.

source

A pointer to the source array.

n

The number of wide characters to be copied.

Description

The wmemcpy function copies n wide characters from the array pointed to by source to the array pointed to by dest.

Return Value

x The value of dest.

wmemmove

Copies a specified number of wide characters from one wide-character array to another.

Format

#include <wchar.h>

wchar_t wmemmove (wchar_t *dest, const wchar_t *source, size_t n);

Function Variants The wmemmove function has variants named _wmemmove32 and _wmemmove64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.10 for more information on using pointer-size-specific functions.

Arguments

dest

A pointer to the destination array.

source

A pointer to the source array.

n

The number of wide characters to be moved.

Description

The wmemmove function copies n wide characters from the location pointed to by source to the location pointed to by dest.

The wmemmove and wmemcpy routines perform the same function, except that wmemmove ensures that the original contents of the source array are copied to the destination array even if the two arrays overlap. Where such overlap is possible, programs that require portability should use wmemmove , not wmemcopy .


Return Value

x The value of dest.

wmemset

Sets a specified value to a specified number of wide characters in an array of wide characters.

Format

#include <wchar.h>

wchar_t wmemset (wchar_t *s, wchar_t c, size_t n);

Function Variants The wmemset function has variants named _wmemset32 and _wmemset64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.10 for more information on using pointer-size-specific functions.

Arguments

s

A pointer to the array of wide characters.

c

The value to be placed in the first n wide characters of the array.

n

The number of wide characters to be set to the specified value c.

Description

The wmemset function copies the value of c into each of the first n wide characters of the array pointed to by s.

Return Value

x The value of s.

wprintf

Performs formatted output from the standard output ( stdout ). See Chapter 2 for information on format specifiers.

Format

#include <wchar.h>

int wprintf (const wchar_t *format, ...);


Arguments

format

A pointer to a wide-character string containing the format specifications. For more information about format and conversion specifications and their corresponding arguments, see Chapter 2.

...

Optional expressions whose resultant types correspond to conversion specifications given in the format specification.

If no conversion specifications are given, the output sources can be omitted. Otherwise, the function calls must have exactly as many output sources as there are conversion specifications, and the conversion specifications must match the types of the output sources.

Conversion specifications are matched to output sources in left-to-right order. Excess output pointers, if any, are ignored.


Description

The wprintf function is equivalent to the fwprintf function with the stdout argument interposed before the wprintf arguments.

Return Values

n The number of wide characters written.
Negative value Indicates an error. The function sets errno to one of the following:
  • EILSEQ -- Invalid character detected.
  • EINVAL -- Insufficient arguments.
  • ENOMEM -- Not enough memory available for conversion.
  • ERANGE -- Floating-point calculations overflow.
  • EVMSERR -- Nontranslatable OpenVMS error. vaxc$errno contains the OpenVMS error code. This might indicate that conversion to a numeric value failed because of overflow.

The function can also set errno to the following as a result of errors returned from the I/O subsystem:

  • EBADF -- The file descriptor is not valid.
  • EIO -- I/O error.
  • ENOSPC -- No free space on the device containing the file.
  • ENXIO -- Device does not exist.
  • EPIPE -- Broken pipe.
  • ESPIPE -- Illegal seek in a file opened for append.
  • EVMSERR -- Nontranslatable OpenVMS error. vaxc$errno contains the OpenVMS error code. This indicates that an I/O error occurred for which there is no equivalent C error code.

wrapok

In the UNIX system environment, allows the wrapping of a word from the right border of the window to the beginning of the next line. This routine is provided only for UNIX software compatibility and serves no function in the OpenVMS environment.

Format

#include <curses.h>

wrapok (WINDOW *win, bool boolf);


Arguments

win

A pointer to the window.

boolf

A Boolean TRUE or FALSE value. If boolf is FALSE, scrolling is not allowed. This is the default setting. The bool type is defined in the <curses.h> header file as follows:


#define bool int


Previous Next Contents Index