Thanks for the quick reply,
I searched the archive and came up with this:
const XMLCh* text = MY_HEBREW_TEXT; // initialized by the parser
XMLTranscoder* utf8Transcoder;
XMLTransService::Codes failReason;
utf8Transcoder =
XMLPlatformUtils::fgTransService->makeNewTranscoderFor("UTF-8", failReason,
16*1024);
int len = XMLString::stringLen(text);
XMLByte* utf8 = new XMLByte(); // ?
unsigned int eaten;
unsigned int utf8Len = utf8Transcoder->transcodeTo(text, len, utf8, len,
eacten, XMLTranscoder::UnRep_Throw);
utf8[utf8Len] = '\0';
string str = (char*)utf8;
return str;
It looks like it works, but problem is that i'm getting a serious memory
leak from this code, and i don't really know why.
i tried to delete the XMLByte*, but when i try to do that, i get a nasty
exception..
Is the code i wrote here is supposed to work? and how can i release the
memory allocated by this code?
Thanks again.
David Bertoni wrote:
>
> pundog wrote:
>> I've got an xml file the contains some Hebrew characters instead of
>> English.
>> I made sure that i saved the file in UTF-8 encoding (using VS.Net), and i
>> also added an xml deceleration line with the encoding attribute set to
>> UTF-8.
>>
>> when i parse the xml, i get an XMLCh* that contains my Hebrew characters,
>> and when i browse it's value in the debugger, i can see the actuall
>> Hebrew
>> characters. However, when i try to convert the XMLCh* to a std::string
>> using
>> the "transcode" method, my string is filled with "????" characters
>> instead
>> of Hebrew.
>
> You need to read the documentation regarding what transcode() does. Since
> it transcodes to the local code page, it's likely your code page doesn't
> support those characters. You probably want to transcode to UTF-8,
> instead
> of the local code page.
>
> If you search the archives of the mailing list, you'll find many postings
> regarding this issue.
>
> Dave
>
>
--
View this message in context:
http://www.nabble.com/Converting-XMLCh*-to-std%3A%3Astring-with-encoding-tf4807661.html#a13765796
Sent from the Xerces - C - Users mailing list archive at Nabble.com.