Each of these character sets has its own charset. The phonetic and Latin charsets are 8−bits wide, while the
ideographic charset is 16−bits wide. Since the charsets must be combined into a single encoding for Japanese text, the
encoding uses shift sequences to specify the character set for each character in a string.
When an encoding contains shift sequences and characters of nonuniform width, strings can still be stored in a
standard NULL−terminated array of characters; this representation is known as a multibyte string. Strings can also be
stored using a wide−character type (wchar_t in ANSI−C) in which each character has a fixed size and occupies one
array element. ANSI−C provides functions that convert between multibyte and wide−character strings and the text
output routines in X11R5 support both types of strings. Multibyte strings are usually more compact than
wide−character strings, but wide−character strings are easier to work with. If an internationalized application performs
any text manipulation, it must take care to handle all strings properly. Fortunately, many applications can do
internationalized text input and output without performing any manipulations on the text.
Multibyte strings are NULL−terminated, while there is no single convention for the termination of wide−character
strings. The following C string−handling routines are safe to use with multibyte strings: strcat(), strcmp(),
strcpy(), strlen(), and strncmp(). The string comparison routines are only useful to check for
byte−for−byte equality; use strcoll() to compare strings for sorting. None of the C string−handling routines work
with wide−character strings.
Multibyte strings can be written to a file or an output stream. If the terminal is operating in the current locale, printing
a multibyte string to stdout or stderr causes the correct text to be displayed. Multibyte strings can also be read
from a file or the stdin input stream. If the file is encoded in the current locale, or the terminal is operating in the
current locale, the strings that are read are meaningful. For a more complete description of working with multibyte
and wide−character strings, see Volume One, Xlib Programming Manual.
The Motif 1.2 Text and TextField widgets provide two resources for specifying their textual data: XmNvalue and
XmNvalueWcs. The XmNvalue resource specifies the text string as a char * value, so it can be used to set the
value of the widget to a multibyte string. XmN-valueWcs specifies the string as a wchar_t * value, so it is used to
set the value to a wide−character string. This resource cannot be specified in a resource file. If XmNvalue and
XmNvalueWcs are both defined, the value of XmNvalueWcs takes precedence.
Regardless of which resource you set, the widgets store the text internally as a multibyte string. The widgets take care
of converting between multibyte strings and wide−character strings when necessary. As a result, you can set the text
string using the XmNvalue resource and retrieve it with XtVaGetValues() using the XmNvalueWcs resource.
The Text widget provides the following convenience routines for manipulating the text value as a wide−character
These routines work for both Text and TextField widgets. The TextField also provides corresponding functions that
only work with TextField widgets. All of these routines function identically to their regular character string
counterparts, except that they take or return wide−character string values. If you have specified the text string using
XmNvalue, you can still use the wide−character string routines because they handle any necessary string
conversions. For more information on the different wide−character routines, see Volume Six B, Motif Reference
15 Text Widgets 15.5.4 Focus Callbacks