Re: Problems with Spanish Chars - Mailing list pgsql-jdbc

From Tony Grant
Subject Re: Problems with Spanish Chars
Date
Msg-id 1058769571.1635.8.camel@vaio
Whole thread Raw
In response to Problems with Spanish Chars  ("Pedro Galan" <pgalan@cscamaras.es>)
List pgsql-jdbc
On Wed, 2003-07-16 at 10:37, Pedro Galan wrote:
> Hello,
>
> I'm trying to use PostgreSQL throught postgresjdbc driver from JSP's pages
> and I am having problems with Spanish special chars.
>
> If I try to insert a text containing any of the following chars á, é, í, ñ
> ... then the result is not correct. I supposse the driver transforms these
> chars into a '?' char.
>
> Any ideas ????

createdb -E LATIN1

for searching from JSP forms try escaping your input with this:

<%! public static String sqlEscape(String str) {
       if(str==null) return(null);
       StringBuffer strBuf = new StringBuffer();
       for(int i=0; i<str.length();i++) {
          char c = str.charAt(i);
          if(c== '\'') {
              strBuf.append(c);
              strBuf.append(c);
          } else {
             strBuf.append(c);
          }
       }
       return(strBuf.toString());
   }
%>

And put sqlEscape around the accented text you want

 (sqlEscape(request.getParameter("someTxt"))   !=null)


Cheers

Tony Grant


pgsql-jdbc by date:

Previous
From: peter mcgregor
Date:
Subject: Calling a stored procedure with array parameters
Next
From: "Arun Desai"
Date:
Subject: Number of function parameter