Thanks, I tried:
char* currentLocale = setlocale(LC_ALL, "");
cout << "currentLocale=" << currentLocale <<
endl;
before initialize xerces.
and this gives me:
currentLocale=LC_CTYPE=de_DE@euro;LC_NUMERIC=de_DE@euro;LC_TIME=de_DE@euro;LC_COLLATE=C;LC_MONETARY=de_DE@euro;LC_MESSAGES=de_DE@euro;LC_PAPER=de_DE@euro;LC_NAME=de_DE@euro;LC_ADDRESS=de_DE@euro;LC_TELEPHONE=de_DE@euro;LC_MEASUREMENT=de_DE@euro;LC_IDENTIFICATION=de_DE@euro
If I call "locale" on command line I get:
LANG=de_DE@euro
LC_CTYPE="de_DE@euro"
LC_NUMERIC="de_DE@euro"
LC_TIME="de_DE@euro"
LC_COLLATE=POSIX
LC_MONETARY="de_DE@euro"
LC_MESSAGES="de_DE@euro"
LC_PAPER="de_DE@euro"
LC_NAME="de_DE@euro"
LC_ADDRESS="de_DE@euro"
LC_TELEPHONE="de_DE@euro"
LC_MEASUREMENT="de_DE@euro"
LC_IDENTIFICATION="de_DE@euro"
LC_ALL=
Now I build the DOMDocument like in
CreateDOMDocument sample,
but with "�papche" instead of "Apache"
then I do the following:
XMLCh tempStr[100];
XMLString::transcode("Core", tempStr, 99);
DOMImplementation *impl
=DOMImplementationRegistry::getDOMImplementation(tempStr);
DOMWriter *theSerializer =
((DOMImplementationLS*)impl)->createDOMWriter();
gOutputEncoding = X("ISO-8859-1" );
theSerializer->setEncoding(gOutputEncoding);
DOMErrorHandler *myErrorHandler = new
DOMPrintErrorHandler();
theSerializer->setErrorHandler(myErrorHandler);
MemBufFormatTarget *myMemBufFormatTarget = new
MemBufFormatTarget();
theSerializer->writeNode(myMemBufFormatTarget,
*doc);
XMLCh* srcString =
myMemBufFormatTarget->getString();
cout << StrX(srcString) << endl;
srcString is now empty and bit later...
MemBufInputSource memBufIS((const
XMLByte*)memString
, strlen(memString)
, gMemBufId
, true
);
crashes !
Is this a bug or do I something wrong ?!
Thomas
Tinny Ng wrote:
>
> The XStr just uses XMLString::transcode which transcodes the string based on
> local codepage. If your char* string is encoded in a codepage different
> from your local page, you cannot use XMLString::transcode. You should
> create your own transcoder instead. For example:
>
> char* to Unicode
> -------------------------------
> 1. If your char* is in the same encoding as your system encoding, then you
> can just call XMLString::transcode to get a unicode XMLCh* string
> e.g.
> XMLCh* result_unicode = XMLString::transcode(source_local);
>
> 2. if your char* is in an encoding other than the system one, then create
> your own transcoder and use transcodeFrom (assume your transcoder supports
> such encoding):
> e.g.
> XMLTranscoder* kkk =
> XMLPlatformUtils::fgTransService->makeNewTranscoderFor("Shift-JIS",
> failReason, 16*1024);
> xxx->transcodeFrom(source_ShiftJIS, length, result_unicode, length,
> bytesEaten, (unsigned char*)charSz);
> where source_ShiftJIS is the source char* in ShiftJIS, while the
> result_unicode is the converted XMLCh* in Unicode
>
> Unicode to char*:
> ------------------------------
> 1. If you want the XMLCh* to be converted to an encoding same as the system
> encoding, then just call XMLString::transcode
> e.g.
> char* result_local = XMLString::transcode(source_unicode);
>
> 2. If you want the XMLCh* to be converted to an encoding different from the
> local one, then create your own transcoder and use transcodeTo (assume your
> transcoder supports such encoding):
> e.g.
> XMLTranscoder* xxx =
> XMLPlatformUtils::fgTransService->makeNewTranscoderFor("Big5", failReason,
> 16*1024);
> xxx->transcodeTo(source_unicode, length, result_Big5, length, charsEaten,
> XMLTranscoder::UnRep_Throw );
> where source_unicode is the source XMLCh*, while the result_Big5 is the
> converted char* in Big5
>
> If you found anything doesn't work, please supply a test case and open a
> bugzilla bug. Thanks!
>
> Tinny
>
> ----- Original Message -----
> From: "Thomas Porschberg" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, September 20, 2002 12:22 PM
> Subject: CreateDOMDocument
>
> I have a question regarding the XStr class in
> CreateDOMDocument.
>
> //
> ---------------------------------------------------------------------------
> // This is a simple class that lets us do easy
> (though not terribly efficient)
> // trancoding of char* data to XMLCh data.
> //
> ---------------------------------------------------------------------------
> class XStr
> ...
>
> Can I expect from the XMLString::transcode method
> that it translate
> umlaute like �,�,� in a correct XMLChar ?
>
> I changed the string "Apache Software Foundation"
> in the sample code
> to "�pache Software Foundation" and the result is
> that the string
> disappears in the output.
>
> from: <developedBy>Apache Software
> Foundation</developedBy>
> to : <developedBy/>
>
> I tried to use a XML88591Transcoder instance in
> conjunction with TranscodeFrom,
> but the same result.
>
> My $LANG environment variable is set to
> "de_DE@euro",
> I set it to "de_DE" and compiled the application
> new, but the same result again.
>
> What is a straightforward way to do this ?
>
> Thomas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]