NAME
nl_tools_16: ADVANCE(), byte_status(), BYTE_STATUS(), CHARADV(), CHARAT(), c_colwidth(), C_COLWIDTH(), firstof2(), FIRSTof2(), secof2(), SECof2(), WCHAR(), WCHARADV() — tools to process 16-bit characters (OBSOLETED AT 10.30)
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.
These macros and functions are obsolete.
See WARNINGS.
DESCRIPTION
The following macros and functions perform their operations
based upon the loaded NLS environment (see
setlocale(3C)).
- FIRSTof2()
Takes a byte and returns a nonzero value
if it can be the first byte of a two-byte character
according to the NLS environment loaded, and zero if it cannot.
- SECof2()
Takes a byte and returns a nonzero 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
BYTE_STATUS(),
C_COLWIDTH(),
FIRSTof2(),
and
SEC0of2(),
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.
- 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()
- c_colwidth()
Subroutine versions of the corresponding macros.
These functions can be called from languages other than C.
EXTERNAL INFLUENCES
Locale
The
LC_CTYPE
category determines the interpretation of single and/or multibyte characters.
WARNINGS
The HP proprietary functions and macros described in this manual entry are
OBSOLETE.
They are not portable to other vendor's systems,
and will not be provided in future HP-UX releases.
For maximum portability, use the routines documented in the
multibyte(3C)
manual entry for multibyte character processing.
Other macros listed in this manual entry
cannot be used as the first argument to
WCHAR()
or
WCHARADV().
For example,
cannot be replaced by
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
SECof2
byte.
AUTHOR
nl_tools_16()
was developed by HP.