Hi All,
I am facing problem while transcoding korean chars on Solaris.
Some details:
Xerces Version: 2.2
Solaris: 5.8
Locale: Korean
The code works fine on AIX and Windows ( for both en_US and korean
locale )
I receive korean data as multie byte char* from database and to
transcode I used the "XMLString::transcode" method.
When I write the transcoded XMLCh* in xml, the string is distorted.
I tried using XMLTranscoder with no results.
To debug the problem I have written a small C style program
(OnlyXerces.cpp) which simulates the output (it receives the korean
chars as argument).
I have attached the program, the console output from the program and the
data from the generated xmls.
Would be great if someone would point out the problem in my code or
divert me to a alternative / better approach.
Regards,
Pushkar
Snippets of code:
setlocale(LC_ALL, ""); // output is received as "ko"
////////// Transcoding using XMLString:transcode//////////
char* strIn = argv[1]; /// argv[1] contains the input korean characters
XMLCh* tag = XMLString::transcode(strIn);
...write xml using "tag"
////////// Transcoding using XMLTranscoder
XMLRecognizer::Encodings encodingEnum = XMLRecognizer::UTF_8;
XMLTranscoder* utf8Transcoder =
XMLPlatformUtils::fgTransService->makeNewTranscoderFor(encodingEnum,
failReason, 16*1024);
XMLCh* outputStr = NULL;
unsigned int charsEaten = 0;
unsigned int length = strlen(strIn);
unsigned char* sizes = new unsigned char[ length + 1 ];
outputStr = new XMLCh[ length ];
unsigned int chars_stored = utf8Transcoder->transcodeFrom((const
XMLByte*) strIn, length, outputStr, length, charsEaten, sizes );
... write xml using "outputStr"