You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Katarzyna Chmurzyńska <kc...@gazeta.pl> on 2005/01/18 08:53:57 UTC

problem with latin2

Hi

I'm writing WEB application where I have to use polish fonts. I have set 
up input and output encodings to iso-8859-2 in velocity.properties, also 
compile application with option  -encoding latin2, templates are also 
set to iso-8859-2. I also use Postgres (database with option -E latin2).
When I read data from database (which contains polish letters) and show 
it in navigator everything is ok.
The problem is when I try to save data from form. After posting it I get 
"?" instead of every polish letter when validation fails, and when 
validation is ok every polish letter is gone (they are cut).
To specify more I use Struts with Velocity.

Has anyone get any similar problem?

K Chmurzyńska



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


Re: problem with latin2

Posted by Katarzyna Chmurzyńska <kc...@gazeta.pl>.
Shinobu Kawai Yoshida wrote:

>public class PolishFilter implements Filter {
>  public void doFilter(ServletRequest request, ServletResponse
>response, FilterChain chain) throws IOException, ServletException {
>    request.setCharacterEncoding("iso-8859-2");
>    chain.doFilter(request, response);
>  }
>}
>  
>
filters work!

thanks

katarzyna chmurzyńska



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


Re: problem with latin2

Posted by Shinobu Kawai Yoshida <sh...@gmail.com>.
Hi guys,

> The problems is often that the text goes trough an extra charset
> encodings/decodings when you try to examine it for debugging purposes,
> and this can obliterate the traces of the root problem. To spot where
> exactly the problem happens, print (e.g. log) the text on various phases
> (e.g. when you get the request parameters) with *character codes*, that
> is, with numbers. Then check if the printed UCS codes are OK at that
> point. (As a catalog of UCS codes you may use "UniBook".)

Adding to Daniel's comment, as it is stated in the javadocs, "This
method must be called prior to reading request parameters or reading
input using getReader()."  So the only feasible solution I find with
Struts is using a Filter.

> >> http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html#setCharacterEncoding(java.lang.String)
> >>
> >>Using Filter works for me.  :)
> >>   http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/Filter.html

And here's an example of what one might look like:
public class PolishFilter implements Filter {
  public void doFilter(ServletRequest request, ServletResponse
response, FilterChain chain) throws IOException, ServletException {
    request.setCharacterEncoding("iso-8859-2");
    chain.doFilter(request, response);
  }
}
## I'm leaving out unimplemented methods.

Best regards,
-- Shinobu

--
Shinobu "Kawai" Yoshida <sh...@gmail.com>

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


Re: problem with latin2

Posted by Daniel Dekany <dd...@freemail.hu>.
Tuesday, January 18, 2005, 11:41:24 PM, Katarzyna Chmurzyńska wrote:

> Shinobu Kawai Yoshida wrote:
>
>>Hi Katarzyna,
>>
>>  
>>
>>>I'm writing WEB application where I have to use polish fonts. I have set
>>>up input and output encodings to iso-8859-2 in velocity.properties, also
>>>compile application with option  -encoding latin2, templates are also
>>>set to iso-8859-2. I also use Postgres (database with option -E latin2).
>>>When I read data from database (which contains polish letters) and show
>>>it in navigator everything is ok.
>>>The problem is when I try to save data from form. After posting it I get
>>>"?" instead of every polish letter when validation fails, and when
>>>validation is ok every polish letter is gone (they are cut).
>>>To specify more I use Struts with Velocity.
>>>    
>>>
>>
>>The only problem is when you get input from the browser, is that
>>correct?  ie. Showing Polish statically or from your database with
>>your template is fine?
>>
>>If so, you should check the encoding of your request.  Does the Polish
>>characters show when you do request.getParameter("so-and-so")?  If
>>not, you need to set the encoding of your request to latin-2.
>>  
>>
> tried and nothing
> before reading from request I call 
> request.setCharacterEncoding("iso-8859-2") and still get "?"

The problems is often that the text goes trough an extra charset
encodings/decodings when you try to examine it for debugging purposes,
and this can obliterate the traces of the root problem. To spot where
exactly the problem happens, print (e.g. log) the text on various phases
(e.g. when you get the request parameters) with *character codes*, that
is, with numbers. Then check if the printed UCS codes are OK at that
point. (As a catalog of UCS codes you may use "UniBook".)

>> http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html#setCharacterEncoding(java.lang.String)
>>
>>Using Filter works for me.  :)
>>   http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/Filter.html

-- 
Best regards,
 Daniel Dekany


____________________________________________________________________
Miert fizetsz az internetert? Korlatlan, ingyenes internet hozzaferes a FreeStarttol.
Probald ki most! http://www.freestart.hu

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


Re: problem with latin2

Posted by Katarzyna Chmurzyńska <kc...@gazeta.pl>.
Shinobu Kawai Yoshida wrote:

>Hi Katarzyna,
>
>  
>
>>I'm writing WEB application where I have to use polish fonts. I have set
>>up input and output encodings to iso-8859-2 in velocity.properties, also
>>compile application with option  -encoding latin2, templates are also
>>set to iso-8859-2. I also use Postgres (database with option -E latin2).
>>When I read data from database (which contains polish letters) and show
>>it in navigator everything is ok.
>>The problem is when I try to save data from form. After posting it I get
>>"?" instead of every polish letter when validation fails, and when
>>validation is ok every polish letter is gone (they are cut).
>>To specify more I use Struts with Velocity.
>>    
>>
>
>The only problem is when you get input from the browser, is that
>correct?  ie. Showing Polish statically or from your database with
>your template is fine?
>
>If so, you should check the encoding of your request.  Does the Polish
>characters show when you do request.getParameter("so-and-so")?  If
>not, you need to set the encoding of your request to latin-2.
>  
>
tried and nothing
before reading from request I call 
request.setCharacterEncoding("iso-8859-2") and still get "?"

>   http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html#setCharacterEncoding(java.lang.String)
>
>Using Filter works for me.  :)
>   http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/Filter.html
>
>
>  
>
not tried with filters but previous solution should work...

any code samples appreciated

k




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


Re: problem with latin2

Posted by Shinobu Kawai Yoshida <sh...@gmail.com>.
Hi Katarzyna,

> I'm writing WEB application where I have to use polish fonts. I have set
> up input and output encodings to iso-8859-2 in velocity.properties, also
> compile application with option  -encoding latin2, templates are also
> set to iso-8859-2. I also use Postgres (database with option -E latin2).
> When I read data from database (which contains polish letters) and show
> it in navigator everything is ok.
> The problem is when I try to save data from form. After posting it I get
> "?" instead of every polish letter when validation fails, and when
> validation is ok every polish letter is gone (they are cut).
> To specify more I use Struts with Velocity.

The only problem is when you get input from the browser, is that
correct?  ie. Showing Polish statically or from your database with
your template is fine?

If so, you should check the encoding of your request.  Does the Polish
characters show when you do request.getParameter("so-and-so")?  If
not, you need to set the encoding of your request to latin-2.
   http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html#setCharacterEncoding(java.lang.String)

Using Filter works for me.  :)
   http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/Filter.html

Best regards,
-- Shinobu

--
Shinobu "Kawai" Yoshida <sh...@gmail.com>

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