You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Dmitri V. Lovtsyus" <ad...@mirror.sp.ru> on 2001/06/03 19:45:31 UTC

Re: request.getParameter() method generate invalid ISO-8859-1 characters for each special UTF-8 character

Здравствуйте M.,

Monday, June 04, 2001, 2:17:03 AM, Вами было написано следующее письмо:

MA> Dear All,
MA> I'm building a mutilaguage website in which i use UTF-8 as the charset for my
MA> servlet but the getParameter() method uses ISO-8859-1 as its default encoding
MA> which results in the unicode characters not found in ISO-8859-1 are mapped
MA> incorrectly to different characters. Such as the special german characters for
MA> each mapped to two incorrect characters. So, how can i enforce the
MA> getParameter() to use UTF-8 to generate valid unicode characters ?

MA> Any help will be appreciated.

    private String qparamNormalized = ""; //normalized string
    
    public synchronized String normalize(String string) {
      if (string == null) return " ";
      else return string;
    }

    public String convert( String qparam )
    {
      qparamNormalized = normalize( qparam );
       try {
             parametr = qparamNormalized.getBytes( "ISO-8859-1" );  
             s   =   new   String(   parametr,   0,  parametr.length,
             "utf-8" );
          } catch ( Exception e ) 
          {
             System.out.println(e.toString());
          }
      if (s.length() != 0) return s; else
      return " ";
    }


-- 
С уважением,
 Dmitri                            mailto:admin@mirror.sp.ru



---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>