You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2004/01/23 16:02:51 UTC

DO NOT REPLY [Bug 26380] New: - Unable to read UTF-8 encoded app.properties

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26380>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26380

Unable to read UTF-8 encoded app.properties

           Summary: Unable to read UTF-8 encoded app.properties
           Product: Struts
           Version: Unknown
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Unknown
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: vesterager@tvi.dk


Hi,

   It really sucks that you have to send your .properties-files through the 
native2ascii converter and get some unreadable gibberish with \uXXXX. I 
realize that even Java doesn't support UTF-8 .properties-files, but writing a 
loader is simple:

    public static Properties loadProperties( String filename) throws Throwable 
{
        Properties result = new Properties();
        BufferedReader reader = new BufferedReader( new InputStreamReader( new 
FileInputStream( filename), "UTF-8"));
        String read = reader.readLine();
        while( read != null) {
            if( !read.startsWith( "#") && !read.startsWith( ";") && 
read.indexOf( '=') != -1)
                result.setProperty( read.substring( 0, read.indexOf( '=')), 
read.substring( read.indexOf( '=')+1, read.length()));
            read = reader.readLine();
        }
        return result;
    }

   Maybe an encoding-attribute could be thrown into the <message-resources>-
tag in struts-config.xml?

Regards,
Torben Vesterager

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org