You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by John Lowenthal <jl...@quickarrow.com> on 2004/05/11 18:37:43 UTC
Character encoding help
Hello,
I am working on a product that uses Turbine and Velocity. We are an
ASP with various international customers who require our output be in UTF-8.
This is simple enough, I just set it in my TurbineResources.properties file
with the following line:
locale.default.charset=UTF-8
Displaying all characters works fine. The problem arises, however, when
accepting input from the users. For normal alpha-numeric characters,
everything works fine, but when the user wants to put in a special character
such as a British Pound sign(£) or accented e(é), incorrect data is being
stored. When the string gets to the action class, the characters are
represented as two new characters in the java String, which are then being
stored as such in our database. When looking at the ParameterParser pulled
from the RunData, I can see that the character encoding is set to
"US-ASCII", where as data.getCharacterEncoding() returns "UTF-8" as it
should.
How can I fix this such that the UTF-8 input is properly interpreted?
Thanks,
-John
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: Character encoding help
Posted by Edgar González <eg...@valhallaproject.com>.
Hello John,
what database are you using to store the data?
Maybe the problem is in the encoding used by the database.
I experienced something like this using Oracle.
Hope this help
----------------------------------------------------------------------
------
Edgar González González
VALHALLA Project, s.a.
Chief Technology Officer
Web: www.valhallaproject.com
E-mail: egg@valhallaproject.com / egg@cantv.net
Phone: +58-212-242.4379 / 6662 / 4055 / 6475
Fax: +58-212-242.6809
"The limits of my language mean the limits of my world."
Ludwig Wittgenstein
----------------------------------------------------------------------
------
John Lowenthal <jl...@quickarrow.com> wrote:
(05/11/2004 12:37)
>Hello,
> I am working on a product that uses Turbine and Velocity. We are an
>ASP with various international customers who require our output be in UTF-8.
>This is simple enough, I just set it in my TurbineResources.properties file
>with the following line:
>
>locale.default.charset=UTF-8
>
>Displaying all characters works fine. The problem arises, however, when
>accepting input from the users. For normal alpha-numeric characters,
>everything works fine, but when the user wants to put in a special character
>such as a British Pound sign(£) or accented e(é), incorrect data is being
>stored. When the string gets to the action class, the characters are
>represented as two new characters in the java String, which are then being
>stored as such in our database. When looking at the ParameterParser pulled
>from the RunData, I can see that the character encoding is set to
>"US-ASCII", where as data.getCharacterEncoding() returns "UTF-8" as it
>should.
>
>How can I fix this such that the UTF-8 input is properly interpreted?
>
>Thanks,
>
>-John
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: turbine-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: Character encoding help
Posted by Paul Kretek <pk...@pugio.net>.
Hi,
I had similar problem with turbine 2.3... everything was working
properly, my app was able to fetch UTF-8 stuff from the database, but
it refused to accept any UTF-8 input from users. After googling around
I found out that it hat something to do with how the servlets fetch the
data from the tomcat environment.
A quick solution for me (I am sure this is not the *best* solution,
please help if you know a better one) was to add a content filter from
the tomcat examples (SetCharacterEncodingFilter.java) to my project. If
you do not have an examples folder in your Webapps directory, download
a 4.* tomcat release and get the file SetCharacterEncodingFilter.java
from there.
Put the file in webapps/<yourapp>/WEB-INF/src/java/filters/ and
recompile the project
add following code to your web.xml
[...]
<web-app>
<!-- start here -->
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>filters.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- end here -->
<servlet>
[...]
I hope this helps,
Paul
On May 12, 2004, at 12:37 AM, John Lowenthal wrote:
> Hello,
> I am working on a product that uses Turbine and Velocity. We are an
> ASP with various international customers who require our output be in
> UTF-8.
> This is simple enough, I just set it in my TurbineResources.properties
> file
> with the following line:
>
> locale.default.charset=UTF-8
[...]
> How can I fix this such that the UTF-8 input is properly interpreted?
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org