20.3 Manipulating Compound Strings
Most C programmers are used to dealing with functions such as strcpy(), strcmp(), and strcat() to copy,
compare, and modify strings. However, these functions do not work with compound strings, as they are not based on a
byte−per−character format, and they may have NULL characters as well as other types of information embedded in
them. In order to perform these common tasks, you can either convert the compound string into a character string, or
you can use the compound string manipulation functions provided by Motif. The method you choose depends largely
on the complexity of the compound strings you have and/or the complexity of the manipulation you need to do.
20.3.1 Compound String Functions
Motif provides a number of functions that allow you to treat compound strings in much the same way that you treat
C−style character arrays. The toolkit provides the following routines:
XmStringByteCompare()
XmStringCompare()
XmStringConcat()
XmStringCopy()
XmStringEmpty()
XmStringHasSubstring()
XmStringLength()
XmStringNConcat()
XmStringNCopy()
Both XmStringCompare() and XmStringByteCompare() compare two compound strings. These routines
take the following form:
Boolean
XmStringCompare(string1, string2)
XmString string1, string2;
Boolean
XmStringByteCompare(string1, string2)
XmString string1, string2;
XmStringCompare() simply checks if the strings have the same text components, directions, and separators; it
returns True if they do. This routine is simpler and more ...