Re: Accent insensitive search? - Mailing list pgsql-general

From Thom Brown
Subject Re: Accent insensitive search?
Date
Msg-id bddc86150903181007x79c03860ue3d24defff517e10@mail.gmail.com
Whole thread Raw
In response to Re: Accent insensitive search?  (Thom Brown <thombrown@gmail.com>)
Responses Re: Accent insensitive search?
Re: Accent insensitive search?
List pgsql-general
Here's an example of a function I might use (although I haven't actually got plperl installed, so can't test it myself, but you'll get the idea:

CREATE OR REPLACE FUNCTION unaccent_string(text) RETURNS text AS $$
my ($input_string) = @_;
$input_string =~ s/[âãäåāăą]/a;
$input_string =~ s/[ÁÂÃÄÅĀĂĄ]/A;
$input_string =~ s/[èééêëēĕėęě]/e;
$input_string =~ s/[ĒĔĖĘĚ]/E;
$input_string =~ s/[ìíîïìĩīĭ]/i;
$input_string =~ s/[ÌÍÎÏÌĨĪĬ]/I;
$input_string =~ s/[óôõöōŏő]/o;
$input_string =~ s/[ÒÓÔÕÖŌŎŐ]/O;
$input_string =~ s/[ùúûüũūŭů]/u;
$input_string =~ s/[ÙÚÛÜŨŪŬŮ]/U;
return $input_string;
$$ LANGUAGE plperl;


Regards

Thom

pgsql-general by date:

Previous
From: Thom Brown
Date:
Subject: Re: Accent insensitive search?
Next
From: Sam Mason
Date:
Subject: Re: Accent insensitive search?