You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Andy Clark <an...@apache.org> on 2003/06/30 03:21:35 UTC

Re: XMLPlatformUtils in Java ?

Markus Jais wrote:
> XMLPlatformUtils::fgTransService->makeNewTranscoderFor(cuni,ret,4096);
> 	delete [] cuni;
> 
> and there are often XMLCh Objects.
> 
> the code transform Strings from 	ISO-8859-1 to UTF-16 and back.

In Java, all Strings and characters are two-byte Unicode. So
you only need to do the conversion on the input and output.
The Reader and Writer classes (and subclasses) in the java.io
package are designed for this purpose. For example:

   InputStream stream = new FileInputStream("file.txt");
   Reader reader = new InputStreamReader(stream, "ISO-8859-1");

   char[] buffer = new char[4096];
   int count = reader.read(buffer);

If you want to do the byte conversion yourself in memory,
then look at the String methods. There are input and output
methods that take an encoding name. (Note: you should use
IANA encoding names.)

That should be enough to get you started.

-- 
Andy Clark * andyc@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org