aevers 2005/03/30 01:53:59
Modified: src/java/org/apache/xmlrpc Tag: XMLRPC_1_2_BRANCH XmlRpc.java Log: Allow the input encoding used to be overridden. The default input encoding is 'null' which produces the orignal behaviour. Overriding the input encoding is necessary on platforms like BS2000 or IBM z/OS where the default encoding (often an EBCDIC variant) is not the same as the network encoding (which for XML-RPC is defined to be ASCII). Revision Changes Path No revision No revision 1.35.2.2 +42 -2 ws-xmlrpc/src/java/org/apache/xmlrpc/XmlRpc.java Index: XmlRpc.java =================================================================== RCS file: /home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/XmlRpc.java,v retrieving revision 1.35.2.1 retrieving revision 1.35.2.2 diff -u -r1.35.2.1 -r1.35.2.2 --- XmlRpc.java 30 Jun 2004 06:09:25 -0000 1.35.2.1 +++ XmlRpc.java 30 Mar 2005 09:53:59 -0000 1.35.2.2 @@ -56,6 +56,7 @@ */ import java.io.InputStream; +import java.io.InputStreamReader; import java.util.Hashtable; import java.util.Stack; import java.util.Vector; @@ -188,6 +189,16 @@ */ static String encoding = XmlWriter.ISO8859_1; + /** + * Java's name for the input encoding we're using. Defaults to + * <code>null</code>, signifying the platform default. This may + * need to be overridden on platforms where the default encoding + * is not compatible with ASCII (eg. EBCDIC) but the network is + * still ASCII-like. + */ + static String inputEncoding = null; + + private TypeFactory typeFactory; /** @@ -342,6 +353,28 @@ } /** + * Set the input encoding of the XML. + * This is used only if set. + * + * @param enc The Java name of the encoding. + */ + public static void setInputEncoding(String enc) + { + inputEncoding = enc; + } + + /** + * Return the input encoding. This may be null. This is always a + * Java encoding name, it is not transformed. + * + * @return the Java encoding name to use, if set, otherwise null. + */ + public static String getInputEncoding () + { + return inputEncoding; + } + + /** * Gets the maximum number of threads used at any given moment. */ public static int getMaxThreads() @@ -440,7 +473,14 @@ } try { - parser.parse(new InputSource (is)); + if(inputEncoding == null) + { + parser.parse(new InputSource (is)); + } + else + { + parser.parse( new InputSource( new InputStreamReader(is, inputEncoding))); + } } finally {