0

Problem with UTF-8 encoding in a Composer

asked 2009-04-17 13:15:09 +0800

fmcypriano gravatar image fmcypriano
612 1 7
http://felipecypriano.com...

Hello,

I'm having a annoying problem. I use IntelliJ IDEA 8.1.1 #9805 and my project is configured to use UTF-8 encoding. The problem is, I made a page (using zk framework, bu I don't it matters) to build a tree for a menu:

And the first item of the tree is:

                        <treerow>
                            <treecell label="Página Inicial"/>
                        </treerow>

This was working and the "á" character appears correct on the browser. But I need to to build the menu from the code to it be dynamic, so I did a java file with this:

     static {
        menuItems = new ArrayList();
        menuItems.add("Página Inicial");
    }

And bound the page to this menuItems, and now when the page is loaded in the browser I get this: "Página Inicial". The meta content type is set correctly to UTF-8.

It only works if I change it to menuItems.add("P\u00E1gina Inicial"), but shouldn't it work without this \u characters?

I'm pretty new to ZK. How composer java source is transformed into a browser page: is the source compiled, or html is generated directly from source, or ... ?

Regards,
Felipe Cypriano

delete flag offensive retag edit

6 Replies

Sort by » oldest newest

answered 2009-04-17 15:09:29 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

Hi Felipe,

look at this thread.

regards
Stephan

link publish delete flag offensive edit

answered 2009-04-17 15:26:23 +0800

fmcypriano gravatar image fmcypriano
612 1 7
http://felipecypriano.com...

Yeah I already looked it. I've the meta tag defined correctly but it doesn't work.

What IMO is more strange is that if I put the special character direct in zul file the HTML is generated correctly, but if I put it in a java composer and set the tree's model to an attribute of the java class the generated html isn't correctly. Why?

Regards,
Felipe Cypriano

link publish delete flag offensive edit

answered 2009-04-20 00:59:07 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

have you checked the encoding of your java class?

link publish delete flag offensive edit

answered 2009-04-20 07:31:20 +0800

ziccardi gravatar image ziccardi
321 7

Probably your charset is not UTF-8.

You shoud try to use the String(byte[] bytes, String charset) constructor, passing "UTF-8" as charset.

My idea is that it would be much better if you put your strings inside an UTF-8 property file, and them use the ZK functions to localize your application (you can use the Labels.getLabel method).

link publish delete flag offensive edit

answered 2009-04-20 07:33:26 +0800

ziccardi gravatar image ziccardi
321 7

Or, in your case, use and UTF-8 property file and change your code to :
<treecell label="${c:l('app.initial.page')}"/>

link publish delete flag offensive edit

answered 2009-04-20 11:23:27 +0800

zalexaka gravatar image zalexaka
3

try JVM option -Dfile.encoding=UTF-8

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-04-17 13:15:09 +0800

Seen: 231 times

Last updated: Apr 20 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More