At 17.59 19/05/2007 -0700, Mihai Matei wrote:
Can you point me to some sample code doing this? Do I have to
recompile the library with this new transcoder?
No, the transcoder is already part of the library. Try something like this:
XMLUTF8Transcoder tx(0, 512);
size_t len = XMLString::stringLen(toTranscode);
const XMLCh* unicode = new XMLCh[len+1];
unsigned int charsEaten= 0;
tx.transcodeFrom(toTranscode, len+1, unicode, len+1, charsEaten,
XMLTranscoder::UnRep_Throw);
...
delete [] unicode;
Alberto
----- Original Message ----
From: Alberto Massari <[EMAIL PROTECTED]>
To: [email protected]
Sent: Friday, May 18, 2007 10:46:40 AM
Subject: Re: UTF-8 characters in CDATA section
The X() macro is a helper class that converts from the local encoding
to Unicode; if you have UTF-8 data, you need to use instead the UTF-8
transcoder.
Alberto
At 02.40 18/05/2007 -0700, Mihai Matei wrote:
>Hi,
>
>I'm trying to add the attached file's contents to a CDATA section in
>an xml. It contains a few Unicode-UTF8 characters from
><http://www.columbia.edu/kermit/utf8-t1.html>http://www.columbia.ed
u/kermit/utf8-t1.html.
>(you can view the file with Firefox, set the Character Encoding to
>Unicode(UTF8)).
>
>//string 'text' has the contents;
>//if I output it to a file with ofstream, the UTF8 characters are preserved
>
>DOMElement* pText = pDoc->createElement( X(tag.c_str()));
>DOMCDATASection* pCdata = pDoc->createCDATASection(X(text.c_str()));
>pText->appendChild(pCdata);
>parent->appendChild(pText);
>
>the resulting xml however loses the UTF-8 characters. Is it the X()
>macro that is to blame, or can I set other XML Document properties
>so I keep my UTF8 chars?
>
>Thanks.
>
>
>Got a little couch potato?
>Check out fun
><http://us.rd.yahoo.com/evt=48248/*http://search.yahoo.com/search?f
r=oni_on_mail&p=summer+activities+for+kids&cs=bz>summer
>activities for kids.
>
>
>
>Ready for the edge of your seat?
><http://us.rd.yahoo.com/evt=48220/*http://tv.yahoo.com/>Check out
>tonight's top picks on Yahoo! TV.
____________________________________________________________________________________Be
a better Heartthrob. Get better relationship answers from someone
who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545433