Convert dynamic strings to and from EBCDIC, Unicode, and UTF-8

To manipulate string variables that are computed at run time, it may be necessary to convert strings to and from extended binary-coded decimal interchange (EBCDIC), Unicode, and UTF-8.

The system API that provides for code page conversion function is iconv(). To use iconv(), follow these steps:

  1. Create a conversion descriptor with QtqIconvOpen().
  2. Call iconv() to use the descriptor to convert to a string.
  3. Close the descriptor by using iconv_close.

In Example 3 of the using the Java™ Native Interface for native methods examples, the routine creates, uses, and then destroys the iconv conversion descriptor within the routine. This scheme avoids the problems with multithreaded use of an iconv_t descriptor, but for performance sensitive code it is better to create a conversion descriptor in static storage, and moderate multiple access to it using a mutual exclusion (mutex) or other synchronization facility.

Related concepts
Literal strings in native methods