Обсуждение: Problems with Spanish Chars

Поиск
Список
Период
Сортировка

Problems with Spanish Chars

От
"Pedro Galan"
Дата:
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 ????


Thanks a lot.


Pedro Galán Caballero
_________________________________________
Responsable Área Técnica
Consejo Superior de Cámaras de Comercio
http://www.camaras.org
Tlf: (+34) 91 590 69 00
Fax: (+34) 91 590 69 08


**********************************************************************************************
-- eSafe escaneó este e-mail en busca de virus y contenido maligno. --

ADVERTENCIA: Este correo electrónico procede del Consejo Superior de
Cámaras de Comercio, Industria y Navegación de España y puede contener
INFORMACIÓN CONFIDENCIAL a la que sólo tiene derecho a acceder el
destinatario. Si  Vd. no es el destinatatario que figura arriba, o la persona
responsable de su entrega al mismo, deberá abstenerse de examinar su
contenido, realizar copias o entregarlo a persona distinta. Si Vd. ha recibido
el correo electrónico por error, le rogamos que nos informe inmediatamente al
número de teléfono 91 590.69.00 o a la dirección de correo electrónico
csc@cscamaras.es
**********************************************************************************************


Re: Problems with Spanish Chars

От
Tony Grant
Дата:
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