Problems with character encoding of text from data model

View: New views
3 Messages — Rating Filter:   Alert me  

Problems with character encoding of text from data model

by Sigurd Stendal :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The characters from my markup pages and my data model is for some reason rendered with different character encoding. The characters in the markup shows up just right, while the exact same text hardcoded in a Label becomes garbage.

This is what i get in the web browser. The web page is utf-8 encoded:

Characters from markup page: æøå
Characters from data model: ʯÂ



From my WebApplication.init():
        getMarkupSettings().setDefaultMarkupEncoding("iso-8859-1");
        this.getRequestCycleSettings().setResponseRequestEncoding("UTF-8");

Java code:
public class ContentPage extends SitePage {
    public ContentPage() {
        add(new Label("target", "Characters from data model: æøå"));
    }
}

Markup:
<html>
<body>
<wicket:extend>
    Characters from markup page: æøå
    <br>
</wicket:extend>    
 </body>
</html>


Has anyone had this kind of problems? Is there any other places where character encoding is defined?


Re: Problems with character encoding of text from data model

by Timo Rantalaiho :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 22 Jul 2008, sstendal wrote:
> rendered with different character encoding. The characters in the markup
> shows up just right, while the exact same text hardcoded in a Label becomes
> garbage.

Are you compiling on Windows by any chance? If not, what is
your system locale when compiling?

I think that javac uses the operating system encoding if you
don't supply one as a command-line parameter. On Windows,
the default is not UTF-8 but something like cp1252 which is
pretty close to ISO-latin 1.

Best wishes,
Timo


--
Timo Rantalaiho          
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Problems with character encoding of text from data model

by Sigurd Stendal :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Timo. I'm compiling on a mac using maven. This has not been a problem before, so I simply didn't think of it.

My java source files are stored in iso-8859-1 (which gives less problems when interacting with people using windows). I specified the encoding in the maven pom-file, and that solved the problem.

It's done like this, in case anyone else has this problem:

<project..>
[...]
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <encoding>iso-8859-15</encoding>
                </configuration>
            </plugin>
[...]
</project>
LightInTheBox - Buy quality products at wholesale price