Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Common Desktop Environment: Internationalization Programmer's Guide > Chapter 3 Internationalization and Distributed Networks

Simple Text Basic Interchange

» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

When a program communicates data to another program residing on a remote host, a need may arise for conversion of data from the code set of the source machine to that of the receiver. For example, this happens when a PC system using PC codes needs to communicate with a workstation using an International Organization for Standardization/Extended UNIX Code (ISO/EUC) encoding. Another example occurs when a program obtains data in one code set but has to display this data in another code set. To support these conversions, a standard program interface is provided based on the XPG4 iconv() function definitions.

All components doing code set conversion should use the iconv functions as their interface to conversions. Systems are expected to provide a wide variety of conversions, as well as a mechanism to customize the default set of conversions.

iconv Conversion Functions

The common method of conversions from one code set to another is through a table-driven method. In some cases, these tables may be too large, hence an algorithmic method may be more desirable. To accommodate such diverse requirements, a framework is defined in XPG4 for code set conversions. In this framework, to convert from one code set to another, open a converter, perform the conversions, and close the converter. The iconv functions are iconv_open(), iconv(), and iconv_close().

Code set converters are brought under the framework of the iconv_open(), iconv(), and iconv_close() set of functions. With these functions, it is possible to provide and to use several different types of converters. Applications can call these functions to convert characters in one code set into characters in another code set. With the advent of the iconv framework, converters can be provided in a uniform manner. The access and use of these converters is being standardized under X/Open XPG4.

X Interclient (ICCCM) Conversion Functions

Xlib provides the following functions for doing conversions.

X ICCCM Multibyte Functions

ICCCM Wide Character Functions

XmbTextPropertyToTextList()

XwcTextPropertyToTextList()

XmbTextListToTextProperty()

XwcTextListToTextProperty()

NOTE: The Motif library does provide the XmCvtXmStringToCT() and XmCvtCtToXmString() functions; however, these are not recommended because there are some hardcoded assumptions about certain XmString tags. For example, if the tag is bold, XmCvtXmStringToCT() is implementation-dependent. Across various platforms, the behavior of this function cannot be guaranteed in all international regions.

Window Titles

The standard way for setting titles is to use resources. But for applications that set the titles of their windows directly, a localized title must be sent to the Window Manager. Use the XCompoundTextStyle encoding defined in XICCEncodingStyle, as well as the following guidelines:

  • Compound text can be created either by XmbTextListToTextProperty() or XwcTextListToTextProperty().

  • Localized titles can be displayed using the XmNtitle and XmNtitleEncoding resources of the WMShell widget. Localized icon names can be displayed using the XmNiconName and XmNiconNameEncoding resources of the TopLevelShell widget.

  • Localized titles of dialog boxes can also be displayed using the XmNdialogTitle resource of the XmBulletinBoard widget.

  • Window Manager should have an appropriate fontlist for displaying localized strings.

Following is an example of displaying a localized title and icon name. Compound text is made from the compound string in this example.

include        <nl_types.h>
Widget toplevel;
Arg al[10];
int ac;
XTextProperty title;
char *localized_string;
nl_catd fd;

XtSetLanguageProc( NULL, NULL, NULL );
fd = catopen( "my_prog", 0 );
localized_string = catgets(fd, set_num, mes_num, "defaulttitle");
XmbTextListToTextProperty( XtDisplay(toplevel), &localized_string,
1, XCompoundTextStyle, &title);
ac = 0;
XtSetArg(al[ac], XmNtitle, title.value); ac++;
XtSetArg(al[ac], XmNtitleEncoding, title.encoding); ac++;
XtSetValues(toplevel, al, ac);

If you are using a window rather than widgets, the XmbSetWMProperties() function automatically converts a localized string into the proper XICCEncodingStyle.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.