Hi Suzanne,

Yes, even if you're on an ASCII system, you must still transcode the UTF-16
code points to the local code page.  Generally, when you end up with
"gibberish," it means the transcoding of the string failed.  That can
happen because the local code page for a particular system may not be able
to represent all Unicode characters.  This is a particular problem with
displaying error messages, and there's no good solution.  Another variable
is that different compilers/runtimes have varying support for Unicode.

You can do a "cheap" transcoder by going through the UTF-16 string and
casting any code point that is less than 128 to a char and printing that
out.  Any characters greater than 128, you can simply substitute an '?', or
some other appropriate character.  That, at least, will get you something,
unless the message you're trying to transcode has no ASCII characters in
it.  That will not work on an EBCDIC system, but you don't seem to be
having any problems there.

On the other hand, this could also be a bug in the code, compiler, or OS,
so it's hard to say.  I haven't experienced any particular problems
building Xalan-C on RedHat 8, but I might be using a different version of
GCC.  The 3.x series of compilers has been somewhat unstable, so you might
want to upgrade to the latest version of GCC and try that.

Dave



                                                                                
                                                  
                      Suzanne Dirkers                                           
                                                  
                      <[EMAIL PROTECTED]         To:      
xalan-c-users@xml.apache.org                                              
                      com>                     cc:      (bcc: David N 
Bertoni/Cambridge/IBM)                                      
                                               Subject: 
TranscodeToLocalCodePage                                                  
                      05/08/2003 05:31                                          
                                                  
                      AM                                                        
                                                  
                                                                                
                                                  







Hi,

        I"m having a problem whereby an Exception message coming back on
Linux is showing up in weird characters. The same message, when
the same code is run on MVS-USS does print out the exception in a readable
format.   I suspect that TranscodeToLocalCodePage(e.getMessage(),
m_errorMessage, true)  is 'translating' something it doesn't need to
translate when you are already in ASCII to begin with? But if I don't use
TranscodeToLocalCodePage at all and just try to print out e.getMessage()
with a printf, that is also gibberish, just different gibberish.  My
question is, if you are already on an ASCII system to begin with, do you
not need to use 'TranscodeToLocalCodePage'? And how then do you print out
an Exception message?

       By the way, this is happening at RH 8  Linux using Xalan 1.4, Xerces
2.1, ICU 2.2.

Thanks,

Suzanne



Reply via email to