Thanks for you info Mark.
  It does appear that a part of my issue stems from my .properties files
being in UTF-8.
So I have to ask the question, why has this changed since if I run the same
code in 5.0.24, I have no issue, and 5.0.28 has a problem.   It sounds like
a substantial problem that UTF-8 resource bundles aren't supported any more.


Besides this simple example, I'm still seeing problems with a servlet
returning XML in UTF-8. Again, no issue in 5.0.24, only after 5.0.25.

I will put together a sample and post it shortly.

Thanks again for the help,

Rick

-----Original Message-----
From: Mark Thomas [mailto:[EMAIL PROTECTED] 
Posted At: Wednesday, September 01, 2004 4:14 PM
Posted To: Tomcat Dev
Conversation: UTF-8 Encoding Issue Since 5.0.27 ( gun in my mouth )
Subject: RE: UTF-8 Encoding Issue Since 5.0.27 ( gun in my mouth )


OK. I have a simple test case and all seems to be well. See the end of this
message for the contents of my test files.

My environment:
Win XP SP2 - brave I know but all has been OK so far ;) JDK 1.4.2_05 Tomcat
5.0 branch, HEAD (latest) from CVS (very close to 5.0.28)

Points to note:
1. All my test files are ASCII files.
2. I had all sorts of problems with non-ASCII properties files. I didn't get
to the bottom of it but I think Windows was adding junk to the start of the
file if it was UTF-8 encoded. Maybe having the first line as a comment would
fix this but I haven't tested this.
3. There were times where Eclipse and Windows were reporting the exact same
file as having different encodings. There is something odd here but I didn't
look at this any further.
4. I had property file issues with 4.1.HEAD as well as 5.0.HEAD.
5. The downside of using ASCII files is that entering the UTF-8 characters
by hand is a real pain. A simple conversion app should fix this though.
6. Apart from the property file issue, everything seems fine.

Test files follow.

Hope this helps,

Mark

PS I noticed that you cross-posted to the dev list. Please don't do this.
Any message cross-posted is less likely rather than more likely to get a
response.

======= utf8.jsp ========
<%@ page language="java" import="java.lang.*,java.util.*"
contentType="text/html; charset=UTF-8" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD
HTML 4.01 Transitional//EN"> <html>
  <head>
    <title>UTF-8 Encoding issue</title>
  </head>
  <body>
    <p>Text from JSP page (which is ASCII encoded).</p>
    <form action="utf8.jsp" method="post">
      <p>English<input type="radio" value="en" name="language" ></p>
      <p>Japanese<input type="radio" value="ja" name="language" ></p>
      <input type="submit" value="Post form data" />
    </form>
    <p>Text from resources bundle:</p>
    <%
      String language = request.getParameter("language");
      
      if (language == null) {
        language="en";
      }
      
      Locale locale = null;
      if (language.equalsIgnoreCase("en")) {
        locale = Locale.ENGLISH;
      } else {
        locale = Locale.JAPAN;
      }
      
      ResourceBundle bundle =
ResourceBundle.getBundle("foo.bar.LocalStrings",
locale);
      out.println("<p>" + bundle.getString("test") + "</p>");
    %>
    <p><%=request.getParameter("language") %></p>
  </body>
</html>

===== LocalStrings_en.properties =====
test=Test string from resources bundle

===== LocalStrings_ja.properties =====
test=\u30d5\u30a1\u30a4\u30eb\u30ed



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to