Re: UTF-8 and LIKE vs = - Mailing list pgsql-general

From Tom Lane
Subject Re: UTF-8 and LIKE vs =
Date
Msg-id 20743.1093301087@sss.pgh.pa.us
Whole thread Raw
In response to Re: UTF-8 and LIKE vs =  (David Wheeler <david@kineticode.com>)
Responses Re: UTF-8 and LIKE vs =  (David Wheeler <david@kineticode.com>)
List pgsql-general
David Wheeler <david@kineticode.com> writes:
> On Aug 23, 2004, at 1:58 PM, Ian Barwick wrote:
>> er, the characters in "name" don't seem to match the characters in the
>> query - '=B1=B9=B9=E6=BA=F1' vs. '=BA=CF=C7=D1=C0=C7' - does that have an=
> y bearing?

> Yes, it means that = is doing the wrong thing!!

I have seen this happen in situations where the strings contained
character sequences that were illegal according to the encoding that the
locale thought was in force.  (It seems that strcoll() will return more
or less random results in such cases...)  In particular, given that you
have

> LC_COLLATE:                           en_US.UTF-8
> LC_CTYPE:                             en_US.UTF-8

you are at risk if the data is not legal UTF-8 strings.

The real question therefore is whether you have the database encoding
set correctly --- ie, is it UNICODE (== UTF8)?  If not then it may well
be that Postgres is presenting strings to strcoll() that the latter will
choke on.

            regards, tom lane

pgsql-general by date:

Previous
From: "Vidyasagara Guntaka"
Date:
Subject: Problems with building libpq for windows
Next
From: Markus Bertheau
Date:
Subject: Re: UTF-8 and LIKE vs =