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]

Reply via email to