Using ANSI C++ Compatible Transcoding Functions

Instead of transcoding directly between IText and IString objects, you can use pointer-based functions, based on the ANSI C++ Standard codecvt functions, that directly manipulate char* and UniChar* data. For example, to convert from char* data into Unicode:

  1. Call ITranscoder::createTranscoder to create a transcoder for the source character set.
  2. Establish the range of the source char array to transcode and create a pointer to iterate through the char array during transcoding.
  3. Allocate a UniChar array to hold the transcoded data and UniChar* variables to use as pointers when iterating through the array during transcoding.
  4. Transcode using the toUnicode function.

For example, this code shows how to transcode a char string into Unicode:

const char* ansiText1 = "An ISO-8859-1 string.";

ITranscoder* transcoder = ITranscoder::createTranscoder("ISO-
8859-1");



UniChar unicodeText[BUFSIZE];

char* ansiText1_next = NULL;

UniChar* unicodeText_end = unicodeText+BUFSIZE;

UniChar* unicodeText_next = NULL;



// Transcode the string

ITranscoder::result res = transcoder->toUnicode(ansiText1,

	ansiText1+strlen(ansiText1), 	ansiText1_next, unicodeText, 

	unicodeText_end, unicodeText_next);

if (res == codecvt_base::ok) {

	// Transcoding was successful

}

delete transcoder;


Transcoding Classes
Transcoder Names