Index: container/src/java/org/apache/pluto/core/impl/PortletResponseImpl.java =================================================================== --- container/src/java/org/apache/pluto/core/impl/PortletResponseImpl.java (revision 126023) +++ container/src/java/org/apache/pluto/core/impl/PortletResponseImpl.java (working copy) @@ -260,7 +260,7 @@ if (wrappedWriter == null) { - wrappedWriter = new PrintWriterServletOutputStream(_getHttpServletResponse().getWriter()); + wrappedWriter = new PrintWriterServletOutputStream(_getHttpServletResponse().getWriter(), _getHttpServletResponse().getCharacterEncoding()); } usingStream = true; Index: container/src/java/org/apache/pluto/util/PrintWriterServletOutputStream.java =================================================================== --- container/src/java/org/apache/pluto/util/PrintWriterServletOutputStream.java (revision 126023) +++ container/src/java/org/apache/pluto/util/PrintWriterServletOutputStream.java (working copy) @@ -22,6 +22,7 @@ import java.io.IOException; import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; import javax.servlet.ServletOutputStream; @@ -40,14 +41,24 @@ PrintWriter mPrintWriter; /** + * Output encoding to display page + */ + private String characterEncoding; + + /** * Construct a ServletOutputStream that coordinates output using a base * ServletOutputStream and a PrintWriter that is wrapped on top of that * OutputStream. */ - public PrintWriterServletOutputStream(PrintWriter pO) + public PrintWriterServletOutputStream(PrintWriter pO, String enc) { super(); mPrintWriter = pO; + characterEncoding = enc; + if (characterEncoding == null) + { + characterEncoding = ""; + } } /** @@ -58,10 +69,23 @@ */ public void write(byte[] pBuf) throws IOException { - char[] cbuf = new char[pBuf.length]; - for (int i = 0; i < cbuf.length; i++) - cbuf[i] = (char)(pBuf[i] & 0xff); - mPrintWriter.write(cbuf, 0, pBuf.length); + String buf = ""; + if (characterEncoding.equals("")) + { + buf = new String(pBuf); + } + else + { + try + { + buf = new String(pBuf, characterEncoding); + } + catch (UnsupportedEncodingException e) + { + buf = new String(pBuf); + } + } + mPrintWriter.write(buf); } /** @@ -82,10 +106,23 @@ */ public void write(byte[] pBuf, int pOffset, int pLength) throws IOException { - char[] cbuf = new char[pLength]; - for (int i = 0; i < pLength; i++) - cbuf[i] = (char)(pBuf[i + pOffset] & 0xff); - mPrintWriter.write(cbuf, 0, pLength); + String buf = ""; + if (characterEncoding.equals("")) + { + buf = new String(pBuf); + } + else + { + try + { + buf = new String(pBuf, pOffset, pLength, characterEncoding); + } + catch (UnsupportedEncodingException e) + { + buf = new String(pBuf, pOffset, pLength); + } + } + mPrintWriter.write(buf); } /**