What do you mean by "non-printable"?  Not every program or console can display 
all characters, and not every program will interpret UTF-8, and not every 
system has the fonts installed to display all of the code points.  I've found 
that if you write UTF-8 to a text document and open it with MS Office Word 
version 2003 or later it tends to display properly.

john

-----Original Message-----
From: Swatilekha Doloi [mailto:[email protected]] 
Sent: Tuesday, March 23, 2010 7:43 AM
To: [email protected]
Subject: transcodeTo results in non-printable chars

Hi,

 

I'm trying to convert non-UTF 8 data to UTF-8. I'm creating a transcoder
to this. The output of the transcodeTo is a bunch of non-printable
characters.

I'm using Xerces 2.8 on Visual Studio 2005.

 

Any help will be much appreciated!

 

//--------------------------------------------------------------//

szBuffer = "Blah here!";

sizeBuffer =  strlen(szBuffer);

 

XMLTransService::Codes failReason;       

XMLRecognizer::Encodings encodingEnum =
XMLRecognizer::encodingForName(XMLUni::fgUTF8EncodingString);

 

XMLTranscoder* utf8Transcoder  =
XMLPlatformUtils::fgTransService->makeNewTranscoderFor(

 
encodingEnum, 

 
failReason,

 
16*1024);

 

int InLength = XMLString::stringLen(szBuffer); 

int OutLength      = InLength * 7;

XMLByte* res = new XMLByte[OutLength]; // output string 

 

// Source string is in Unicode, want to transcode to UTF-8

unsigned int charsEaten = 0; 

unsigned int total_chars = 0;

total_chars = utf8Transcoder->transcodeTo((const XMLCh*)szBuffer,

 
InLength,

 
res,

 
OutLength - 1,

 
charsEaten,

 
XMLTranscoder::UnRep_Throw);

Reply via email to