Il 12/09/2013 22:34, Roberto Scattini
ha scritto:
The problem is the encoding: SQL_ASCII encodes only the first 128 characters, so 'ñ' and 'Ñ' cannot be encoded in ASCII. If you insert text 'ñ' or 'Ñ' in a table inside a database (e.g. 'ascii_test') with SQL_ASCII encoding, they will be seen as two distinct characters: ascii_test=# SELECT length(E'ñ'); length -------- 2 (1 row) ascii_test=# SELECT length(E'Ñ'); length -------- 2 (1 row) ascii_test=# SELECT 'ñ'::bytea; bytea -------- \xc3b1 (1 row) ascii_test=# SELECT 'Ñ'::bytea; bytea -------- \xc391 (1 row) Hexadecimals 'c3', 'b1' and '91' does not decode anything in ASCII, even if terminal show pairs as 'ñ' or 'Ñ'. So ILIKE operator cannot apply case insensitive pattern matching to data which does not encode any string (in the SQL_ASCII encoding) and works as a normal LIKE. Even if the client which insert data has 8-bit encoding (UTF8, where 'ñ' and 'Ñ' are decoded), SQL_ASCII database cannot convert strings anyway, and problem remains. The best way is to work with a UTF8 encoded database. Is there a particular reason to work with SQL_ASCII encoding? Giuseppe. -- Giuseppe Broccolo - 2ndQuadrant Italy PostgreSQL Training, Services and Support giuseppe.broccolo@xxxxxxxxxxxxxx | www.2ndQuadrant.it |