Author: jfrederic.clere(a)jboss.com
Date: 2009-08-04 12:40:02 -0400 (Tue, 04 Aug 2009)
New Revision: 1141
Modified:
trunk/java/org/apache/tomcat/util/buf/C2BConverter.java
Log:
Fix for JBAS-6442
Modified: trunk/java/org/apache/tomcat/util/buf/C2BConverter.java
===================================================================
--- trunk/java/org/apache/tomcat/util/buf/C2BConverter.java 2009-08-04 16:33:39 UTC (rev
1140)
+++ trunk/java/org/apache/tomcat/util/buf/C2BConverter.java 2009-08-04 16:40:02 UTC (rev
1141)
@@ -25,6 +25,7 @@
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
import java.nio.charset.UnsupportedCharsetException;
+import java.nio.charset.CodingErrorAction;
/**
* NIO based character encoder.
@@ -46,7 +47,10 @@
public C2BConverter(String charset)
throws IOException {
try {
+ byte[] newReplacement = { (byte)'?' };
encoder = Charset.forName(charset).newEncoder();
+ encoder = encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
+ encoder = encoder.replaceWith(newReplacement);
} catch (UnsupportedCharsetException e) {
throw new UnsupportedEncodingException(charset);
}
Show replies by date