HTML Output in Facelets

Hello,

I’ve a problem concerning special characters (é,è,à,ç,…).
When I render the output to a ByteArrayOutputStream and write this to a file
(CODE

ByteArrayOutputStream os = (ByteArrayOutputStream)… a method returning the special characters

FileOutputStream fos = new FileOutputStream ( “c:/BAOSTest” ) ;
os.writeTo ( fos ) ;

os.flush();
fos.close ( ) ;
)
then the characters are displayed ok.

But, when rendering the characters using the ResponseWriter, the characters are invalid (something like ç à é). The output encoding of the ResponseWriter is UTF-8, where it should be ISO-8859-1.

Is there a way to change this mapping, or is there a workaround to display the characters as valid on screen (in HTML) ?

many thanks,

Rudi Welter

why don’t you just use the same character encoding for both. If the ResponseWriter should be ISO-8859-1 then just set it to that.

How do I change this. ResponseWriter has a public method for inquiring the character encoding but no method for changing it. It is handled by Facelets themselves.

Thanks

Ok, I solved it.

// retrieve contents from DB
byte dbcontent = reportVO.getReportDesign();

// create an input stream of it
InputStream is = new ByteArrayInputStream(dbcontent);

// return a treated output stream (byte array output stream)
ByteArrayOutputStream os = (ByteArrayOutputStream) ReportEngineService.getInstance().runAndRenderReportAsHtmlStream(is, options.getRequest());

// create a new string with encoding UTF-8 (even if the encoding is UTF-8, you never know what the db driver does)
String output = os.toString(“UTF-8”);

// get ResponseWriter
ResponseWriter writer = options.getContext().getResponseWriter();

// render it
os.flush();
writer.write (output);

Rudi