Author: markt
Date: Thu Oct  2 13:57:44 2014
New Revision: 1628978

URL: http://svn.apache.org/r1628978
Log:
Add the ability to control the Charset used for String<->byte conversions. The 
default remains ISO-8859-1 so this should have no functional impact.

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/buf/MessageBytes.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/MessageBytes.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/MessageBytes.java?rev=1628978&r1=1628977&r2=1628978&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/buf/MessageBytes.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/buf/MessageBytes.java Thu Oct  2 
13:57:44 2014
@@ -18,7 +18,7 @@ package org.apache.tomcat.util.buf;
 
 import java.io.IOException;
 import java.io.Serializable;
-import java.nio.charset.StandardCharsets;
+import java.nio.charset.Charset;
 import java.util.Locale;
 
 /**
@@ -201,6 +201,20 @@ public final class MessageBytes implemen
         return strValue;
     }
 
+    /**
+     * Get the Charset used for string<->byte conversions.
+     */
+    public Charset getCharset() {
+        return byteC.getCharset();
+    }
+
+    /**
+     * Set the Charset used for string<->byte conversions.
+     */
+    public void setCharset(Charset charset) {
+        byteC.setCharset(charset);
+    }
+
     /** Do a char->byte conversion.
      */
     public void toBytes() {
@@ -210,7 +224,7 @@ public final class MessageBytes implemen
         }
         toString();
         type=T_BYTES;
-        byte bb[] = strValue.getBytes(StandardCharsets.ISO_8859_1);
+        byte bb[] = strValue.getBytes(byteC.getCharset());
         byteC.setBytes(bb, 0, bb.length);
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to