Multibyte Character Support

In the examples that follow, multibyte_char represents any string of one or more multibyte characters.

String Literals and Character Constants

Multibyte characters are supported in string literals and character constants. Strings containing multibyte characters are treated in essentially the same way as strings without multibyte characters. Multibyte characters can appear in several contexts:

Wide-character strings can be manipulated the same way as single-byte character strings. The system provides equivalent wide-character and single-byte string functions.

The default storage type for all string literals is read-only. The -qro option sets the storage type of string literals to read-only, and the -qnoro option makes string literals writable.

Note: Because a character constant can store only 1 byte, avoid assigning multibyte characters to character constants. Only the last byte of a multibyte character constant is stored. Use a wide-character representation instead. Wide-character string literals and constants must be prefixed by L. For example:

wchar_t *a = L"wide_char_string" ;
wchar_t b = L'c'

Preprocessor Directives

The following preprocessor directives permit multibyte-character constants and string literals:

Macro Definitions
Because string literals and character constants can be part of #define statements, multibyte characters are also permitted in both object-like and function-like macro definitions.

Compiler Options

Multibyte characters can appear in the compiler suboptions that take file names as arguments:

The -D name=definition option permits multibyte characters in the definition of the macro name. In the following example, the first definition is a string literal, and the second is a character constant:

-DMYMACRO="kpsmultibyte_chardcs"
-DMYMACRO='multibyte_char'

The -qmbcs compiler option permits both double-byte and multibyte characters. In other respects, it is equivalent to the -qdbcs option, but it should be used when multibyte characters appear in the program.

The listings produced by the -qlist and -qsource options display the date and time for the appropriate international language. Multibyte characters in the file name of the C or C++ source file also appear in the name of the corresponding list file. For example, a C source file called:

multibyte_char.c

gives a list file called

multibyte_char.lst

File Names and Comments

Any file name can contain multibyte characters. The file name can be a relative or absolute path name. For example:

#include<multibyte_char/mydir/mysource/multibyte_char.h>
#include "multibyte_char.h"

xlC /u/myhome/c_programs/kanji_files/multibyte_char.c
-omultibyte_char

Multibyte characters are also permitted in comments, if you specify the -qmbcs compiler option.

Restrictions



National Language Support in VisualAge C++
Where Multibyte Characters are Supported
dbcs Compiler Option
mbcs Compiler Option
# Operator