You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Galam <ga...@gmail.com> on 2006/05/27 07:35:16 UTC

Can't get Tapestry to work with UTF-8 encoding

Hi all,

I couldn't seem to make Tapestry to work with the UTF-8 encoding.

I am using Tomcat 5.5.12. As far as I know, the tomcat is setup correctly
because it has no problem returning UTF-8 responses for jsp and non-tapestry
HTML pages.


Here are my Home.page and Home.html.


Home.page
-----

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE page-specification PUBLIC "-//Apache Software Foundation//Tapestry
Specification 4.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
<page-specification class="com.ttdev.HelloWorld.Home">
    <component id="subject" type="Insert">
        <binding name="value" value="greetingSubject"/>
    </component>
</page-specification>


Home.html
---------------

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>hello <span jwcid="subject">world</span>!</p>
<p>中文测试</p>  (harded chinese text here, but it shown up as garbage )
<BR>
TEST2

</body>
</html>




Besides the content type declaration in the files, the files themselves are
also encoded in UTF-8. But when I run the appllication, the hard-coded
chinese text shown up as garbage.
Am I missing something? What are the proper settings to create a UTF-8
application in Tapestry.

Thanks!


Galam.

Re: Can't get Tapestry to work with UTF-8 encoding

Posted by Galam <ga...@gmail.com>.
Specifying the encoding in the *.application file doens't work (I've tried
all three encoding options below, none of them work).

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC "-//Apache Software Foundation//Tapestry
Specification 4.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
<application>
    <meta key="org.apache.tapestry.output-encoding" value="UTF-8"/>
    <meta key="org.apache.tapestry.messages-encoding" value="UTF-8"/>
    <meta key="org.apache.tapestry.template-encoding" value="UTF-8"/>
</application>


The only thing that works is by passing the  "-Dfile.encoding=UTF-8" option
to the java.exe in the catalina startup script.






On 5/28/06, James Carman <ja...@carmanconsulting.com> wrote:
>
> in your .application file
>

Re: Can't get Tapestry to work with UTF-8 encoding

Posted by Paul Cantrell <ca...@pobox.com>.
I specify the option in WEB-INF/tapestry.application. I see you  
already wrote that this didn't work for you ... don't know what to  
tell you! It works for me.

> I would like to give it a try. Also, where can I find a complete of
> <meta...> keys for Tapestry 4?

http://jakarta.apache.org/tapestry/UsersGuide/configuration.html



On May 28, 2006, at 9:37 PM, Galam wrote:

> Hi Paul,
>
> Can you tell me where you specify the following options?
>
>   <meta key="org.apache.tapestry.template-encoding" value="utf-8"/>
>
>
> I would like to give it a try. Also, where can I find a complete of
> <meta...> keys for Tapestry 4?
>
>
> Thanks!
>
> Galam.
>
>
> On 5/28/06, Paul Cantrell <ca...@pobox.com> wrote:
>>
>> This option works for me:
>>
>>      <meta key="org.apache.tapestry.template-encoding"  
>> value="utf-8"/>
>>
>> This has the advantage that you don't need control over the startup
>> params of the container's JVM.
>>
>> P

_________________________________________________________________
Piano music podcast: http://inthehands.com
Other interesting stuff: http://innig.net



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


RE: Can't get Tapestry to work with UTF-8 encoding

Posted by James Carman <ja...@carmanconsulting.com>.
in your .application file

-----Original Message-----
From: Galam [mailto:galam.ny@gmail.com] 
Sent: Sunday, May 28, 2006 10:38 PM
To: Tapestry users
Subject: Re: Can't get Tapestry to work with UTF-8 encoding

Hi Paul,

Can you tell me where you specify the following options?

   <DEFANGED_meta key="org.apache.tapestry.template-encoding"
value="utf-8"/>


I would like to give it a try. Also, where can I find a complete of
<DEFANGED_meta...> keys for Tapestry 4?


Thanks!

Galam.


On 5/28/06, Paul Cantrell <ca...@pobox.com> wrote:
>
> This option works for me:
>
>      <DEFANGED_meta key="org.apache.tapestry.template-encoding"
value="utf-8"/>
>
> This has the advantage that you don't need control over the startup
> params of the container's JVM.
>
> P



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


Re: Can't get Tapestry to work with UTF-8 encoding

Posted by Galam <ga...@gmail.com>.
Hi Paul,

Can you tell me where you specify the following options?

   <meta key="org.apache.tapestry.template-encoding" value="utf-8"/>


I would like to give it a try. Also, where can I find a complete of
<meta...> keys for Tapestry 4?


Thanks!

Galam.


On 5/28/06, Paul Cantrell <ca...@pobox.com> wrote:
>
> This option works for me:
>
>      <meta key="org.apache.tapestry.template-encoding" value="utf-8"/>
>
> This has the advantage that you don't need control over the startup
> params of the container's JVM.
>
> P

Re: Can't get Tapestry to work with UTF-8 encoding

Posted by Paul Cantrell <ca...@pobox.com>.
This option works for me:

     <meta key="org.apache.tapestry.template-encoding" value="utf-8"/>

This has the advantage that you don't need control over the startup  
params of the container's JVM.

P

On May 27, 2006, at 1:16 AM, Galam wrote:

> Hi Sam,
>
>
> Thank you so much for the quick response.
>
> The jvm option "-Dfile.encoding=UTF-8" works perfectly!
>
>
> Galam.

_________________________________________________________________
Piano music podcast: http://inthehands.com
Other interesting stuff: http://innig.net



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


Re: Can't get Tapestry to work with UTF-8 encoding

Posted by Galam <ga...@gmail.com>.
Hi Sam,


Thank you so much for the quick response.

The jvm option "-Dfile.encoding=UTF-8" works perfectly!


Galam.

Re: Can't get Tapestry to work with UTF-8 encoding

Posted by Sam Gendler <sg...@ideasculptor.com>.
If you take dojo out of the page entirely, but serve it from the exact
same location, does it work correctly?  I had some wierd issues with
the way java uses the default charset of the jvm when reading a file,
so even if tomcat (or any other java app) is set to handle utf-8,
things can still get garbled when a file gets read by the jvm if the
charset for the input stream is not set explicitly and the default
charset of your jvm is not utf-8.  The only way to set the default
charset (which is the only charset that gets used if you don't set a
charset in all readers and writers explicitly) is to set a system
property at the time that the jvm starts up.  You cannot modify it
once the jvm is running.  Generally, you just pass a -D option to java
when you run it:

-Dfile.encoding=UTF-8

Try doing this (if you are running tomcat, just put this in an
environment variable called JAVA_OPTS before starting tomcat):

csh:
setenv JAVA_OPTS "-Dfile.encoding=UTF-8"

bash:
export JAVA_OPTS="-Dfile.encoding=UTF-8"

and see if it doesn't fix your problem.

--sam

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