Nikola Milutinovic wrote: > Ivo Panacek wrote: > >>> response.setContentType("text/html; charset=ISO-8859-2"); >>> >>> So, no trouble there. How do I get a (Unicode) string to convert to a >>> ISO-8859-2 encoded byte stream? Because, eventually, that is what the >>> browser should get. I cannot use the method from above, since >>> JspWriter doesn't accept byte[] as an argument. >> >> >> >> Java does it for you. If you retrieve output stream AFTER setting >> content type >> with out = pageContext.getOut(); you write to out in UNICODE and output >> is in ISO-8859-2. > > > Hmmm, since I'm in a JSP page and not Servlet, this should be done > automagically. When I run Jasper on the "test.jsp" file, this is what I
Aha. I use JSP only too and it works for me. My configuration is: RedHat 7.1 + Apache + jdk 1.3 (blackdown) + Tomcat 4.0.1 + webapp module. This was my testing page: <%-- <%@ page contentType="text/html;charset=ISO-8859-2" %> <%@ page pageEncoding="ISO-8859-2" %> --%> <%@ page contentType="text/html;charset=UTF-8" %> <%@ page pageEncoding="UTF-8" %> <%@ page import="HelloBean3" %> <jsp:useBean id="mojeAhojFazole3" class="HelloBean3" scope="session"/> <jsp:setProperty name="mojeAhojFazole3" property="*"/> <html> <head><title>mojeAhojFazole3</title></head> <body bgcolor="white" onLoad="focusInput()"> <p> Gratuluji, tohle opravdu je funkc(ní JSP aplikace, která dokonce ne(co de(lá. </p> ... form testing Both UTF-8 and ISO-8859-2 versions worked well, tested with Mozilla (0.9.x) on Linux and IE on Windows. ISO-8859-2 characters were in html text, but relevant part of resulting java is: out.write("\r\n\r\n<html>\r\n<head><title>mojeAhojFazole3</title></head>\r\n<body bgcolor=\"white\">\r\n\r\n<p>\r\nGratuluji, tohle opravdu je funkÄnA( JSP aplikace,\r\nkterA(A; dokonce nÄ?co dÄ?lA(A;.\r\n</p>\r\n<p><hr></p>\r\n\r\n"); ... so simple out.write, text is in default UTF-8. Problem was only with input from forms. Testing showed, that browser does not write encoding in mime headers, but it use the same encoding as in original page. So I use simple filter (found via this mail-list -- name was SetCharacterEncodingFilter.java -- I can send it) and now I have no problems. > %> > <%! > String testText; > %> > <% > testText = "\uC5A0 \uC5A1 \uC486 \uC487 \uC48C \uC48D \uC490 \uC491 \uC5BD \uC5BE"; > %> Just one idea: what are those unicode characters ? I've just tested this code: public static void main( String args[] ) { String text1 = "\uC5A0 \uC5A1 \uC486 \uC487 \uC48C \uC48D \uC490 \uC491 \uC5BD \uC5BE"; String text2 = "e(s(c(r(z(ýáíé"; try { PrintWriter wr = new PrintWriter( new OutputStreamWriter( System.out, "8859_2" ) ); wr.println("\""+text1+"\""); wr.println("\""+text2+"\""); wr.close(); } catch( Exception e ) { System.err.println("Error: "+e); } } } And result is: "? ? ? ? ? ? ? ? ? ?" "e(s(c(r(z(ýáíé" ivo -- E-mail: [EMAIL PROTECTED], [EMAIL PROTECTED] WWW: http://ivop.regionet.cz Mobile: +420 602 337776 -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>