Mark Wilson I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :
03/24/2008
Times viewed :
526
Xalan: The org.apache.xml.serializer.Encodings Class
This
class provides information about encodings. Depends on the Java runtime to provide
writers for the different encodings, but can be used to override encoding names
and provide the last printable character for each encoding.
Sometimes
we need to override the current encoding type. This class helps to provide
different to encoding types.
Method Overviews
Most of
the methods in this class are static. So you can use method in this class
without creating an instance of this class. It is the job of java runtime to
convert to different encoding type. Most of the times, I have used convertJava2MimeEncoding() method to convert
a string into Mime type.
Example of convertJava2MimeEncoding(java.lang.String
encoding):
Try the
best we can to convert a Java encoding to a XML-style encoding. It takes parameters
a non-null reference to encoding string, java style and returns ISO-style
encoding string.
String needstobeMimeType="Your
string to be enoded into mime type";
String newText =
Encodings.convertJava2MimeEncoding(needstobeMimeType); In the above example, I
have used created a Properties object using
Example of convertMime2JavaEncoding(java.lang.String
encoding):
This
method does opposite to the above method. It converts mime type encoding to
java type encoding.
String
needstobeJavaType="Your string to be enoded into Java type";
Example of getWriter(java.io.OutputStream output,
java.lang.String encoding)throws
java.io.UnsupportedEncodingException:
Returns
a writer for the specified encoding based on an output stream. If you want a
Writer instance with a specified encoding type the use this method. This method
helps a lot for internationalization where you will be dealing with different
encoding types.