HPUX nl_tools_16[3c]

nl_tools_16(3C) nl_tools_16(3C)
NAME
firstof2(), secof2(), byte_status(), c_colwidth(), FIRSTof2(),
SECof2(), BYTE_STATUS(), C_COLWIDTH(), CHARAT(), ADVANCE(), CHARADV(),
WCHAR(), WCHARADV() - tools to process 16-bit characters
SYNOPSIS
#include <nl_ctype.h>
int firstof2(int c);
int secof2(int c);
int byte_status(int c, int laststatus);
int c_colwidth(int c);
int FIRSTof2(int c);
int SECof2(int c);
int BYTE_STATUS(int c, int laststatus);
int C_COLWIDTH(int c);
int CHARAT(const char *p);
int ADVANCE(const char *p);
int CHARADV(const char *p);
int WCHAR(wchar_t wc, char *p);
int WCHARADV(wchar_t wc, char *p);
void PCHAR(int c, char *p);
void PCHARADV(int c, char *p);
Remarks
All interfaces listed above whose names begin with a capital letter are
implemented as macros; the others are functions.
DESCRIPTION
The following macros and routines perform their operations based upon
the loaded NLS environment (see setlocale(3C)).
FIRSTof2() Takes a byte and returns a non-zero value if it
can be the first byte of a two-byte character
according to the NLS environment loaded, and zero
if it cannot.
Hewlett-Packard Company - 1 - HP-UX Release 9.0: August 1992
nl_tools_16(3C) nl_tools_16(3C)
SECof2() Takes a byte and returns a non-zero value if it
can be the second byte of a two-byte character
according to the loaded NLS environment, and zero
if it cannot.
BYTE_STATUS() Returns one of the following values based on the
value of the current byte in c and the status of
the previous byte interpreted in laststatus as
returned by the last call to BYTE_STATUS(). These
are the status values as defined in <nl_ctype.h>:
ONEBYTE Single-byte character
SECOF2 Second byte of two-byte
character
FIRSTOF2 First byte of two-byte
character
To validate a two-byte character, both the first
and second bytes must be valid. If the value of
laststatus is FIRSTOF2 but SECof2(c) returns
false, BYTE_STATUS(c, laststatus) returns ONEBYTE.
C_COLWIDTH() Takes a byte which is assumed to be either a one-
byte character or the first byte of a two-byte
character, and returns the number of columns the
character would occupy on a terminal display.
For the macros FIRSTof2(), SEC0of2(),
BYTE_STATUS() , and C_COLWIDTH() results are
undefined for values of c less than -1 (EOF) or
greater than 255.
CHARAT() Takes as an argument a pointer p, which is assumed
to be pointing at either a one-byte character or
the first byte of a two-byte character. In either
case, CHARAT() returns the wchar_t value that
corresponds to the character pointed to by p.
ADVANCE() Advances its pointer argument by the byte width of
the character it is pointing at (either one or two
bytes).
CHARADV() Combines the functions of CHARAT() and ADVANCE()
in a single macro. It takes as an argument a
pointer p, which is assumed to be pointing at
either a one-byte character or the first byte of a
two-byte character. In either case CHARADV()
returns the wchar_t value that corresponds to the
character pointed to by p, and advances p beyond
the last byte of the character.
Hewlett-Packard Company - 2 - HP-UX Release 9.0: August 1992
nl_tools_16(3C) nl_tools_16(3C)
WCHAR() Converts the wchar_t value wc into the
corresponding one or two byte character, and
writes it at the location specified by p. WCHAR()
returns the wchar_t value wc.
WCHARADV() Combines the functions of WCHAR() and ADVANCE() in
a single macro. It converts the wchar_t value wc
into the corresponding one or two byte character,
and writes it at the location specified by p, then
advances p past the last byte. WCHARADV() returns
the wchar_t value wc.
firstof2()
secof2()
byte status() Subroutine versions of the corresponding macros.
c colwidth() These functions can be called from languages other
than C.
EXTERNAL INFLUENCES
Locale
The LC_CTYPE category determines the interpretation of single and/or
multi-byte characters.
WARNINGS
For maximum portability, use the routines documented in the
multibyte(3C) manual entry for multi-byte character processing.
Other macros listed in this manual entry cannot be used as the first
argument to WCHAR() or WCHARADV(). For example,
*t++ = *f++
cannot be replaced by
WCHARADV(CHARADV (f),t).
Instead, use a method such as
int c; ... c = CHARADV (f), WCHARADV (c,t).
WCHAR() and WCHARADV() may produce a "null effect" warning from
lint(1) if not used as part of another expression or as part of a
statement. This does not affect the functionality of either macro.
Note that WCHAR() and WCHARADV() are not ``replace_char'' macros.
They do not prevent the second byte of a two-byte character from being
left dangling if WCHAR() or WCHARADV() overwrite the first byte of the
two-byte character with a single-byte character.
CHARAT(), ADVANCE(), and CHARADV() do not examine the byte following
the location pointed to by the argument to verify its validity as a
Hewlett-Packard Company - 3 - HP-UX Release 9.0: August 1992
nl_tools_16(3C) nl_tools_16(3C)
SECof2 byte.
AUTHOR
nl_tools_16() was developed by HP.
SEE ALSO
setlocale(3C), multibyte(3C), wconv(3X), wctype(3X), hpnls(5).
Hewlett-Packard Company - 4 - HP-UX Release 9.0: August 1992