C/C++ Programmer's Guide (G06.25+)
HP C Implementation-Defined Behavior
HP C/C++ Programmer’s Guide for NonStop Systems—429301-008
A-28
G.5 Common Extensions
Wide characters are integers of type wchar_t, defined in the headers stddef.h 
and stdlib.h as:
typedef unsigned short wchar_t;
Such an integer can represent distinct codes for each of the characters in the 
extended character set. The codes for the basic C character set have the same 
values as their single-character forms.
Relationship Between Multibyte and Wide Characters:
•
Multibyte characters are convenient for communicating between the program and 
the outside world.
•
Wide characters are convenient for manipulating text within a program.
•
The fixed size of wide characters simplifies handling both individual characters and 
arrays of characters.
MB_CUR_MAX Macro:
•
The MB_CUR_MAX macro specifies the maximum number of bytes used in 
representing a multibyte character in the current locale (category LC_CTYPE). The 
MB_CUR_MAX macro is defined in the header stdlibh as:
#define MB_CUR_MAX 2
Conversion Functions:
•
The five run-time library functions that manage multibyte characters and wide 
characters are: 
Alignment Issues
TNS C and C++ considers objects of integral types to exist only on word boundaries. 
Consequently, it is invalid to use an odd-byte address to access such an object. On 
TNS systems, if an integral type extended pointer contains an odd-byte address, the 
system ignores the last bit of the address and accesses the object in the even address 
one byte below. On TNS/R and TNS/E systems, the results of using an integral type 
extended pointer containing an odd-byte address are undefined. The code might 
continue executing or trap. Therefore, it is important for you to ensure that all extended 
pointers contain addresses that are even except for pointers to char. Extended 
Function Description
mblen() Determines the length of a multibyte character.
mbtowc() Converts a multibyte character to a wide character.
wctomb() Converts a wide character to a multibyte character.
mbstowcs() Converts a string of multibyte characters to a string of wide 
characters.
wcstombs() Converts a string of wide characters to a string of multibyte 
characters.










