pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedRFC: i18n2ascii(TEXT) stored procedure
5+ messages / 4 participants
[nested] [flat]
* RFC: i18n2ascii(TEXT) stored procedure
@ 2003-09-25 23:50 Michael A Nachbaur <mike@nachbaur.com>
2003-09-26 00:06 ` Re: RFC: i18n2ascii(TEXT) stored procedure Manuel Sugawara <masm@fciencias.unam.mx>
2003-09-26 06:30 ` Re: RFC: i18n2ascii(TEXT) stored procedure Peter Eisentraut <peter_e@gmx.net>
2003-09-26 14:10 ` Re: RFC: i18n2ascii(TEXT) stored procedure scott.marlowe <scott.marlowe@ihs.com>
0 siblings, 3 replies; 5+ messages in thread
From: Michael A Nachbaur @ 2003-09-25 23:50 UTC (permalink / raw)
To: pgsql-sql
I've created the following stored procedure to allow me to do
international-insensitive text searches, e.g. a search for "Resume" would
match the text "Résumé".
I wanted to know:
a) am I missing any characters that need to be converted? My first (and only
language) is English, so I'm in the dark when that is concerned;
b) is there a better and/or faster way of implementing this? I don't want
searches to bog down (at least too badly) as a result of this.
CREATE OR REPLACE FUNCTION i18n2ascii (TEXT) RETURNS TEXT AS '
my ($source) = @_;
$source =~
tr/áàâäéèêëíìîïóòôöúùûüÁÀÂÄÉÈÊËÍÌÎÏÓÒÔÖÚÙÛÜ/aaaaeeeeiiiioooouuuuAAAAEEEEIIIIOOOOUUUU/;
return $source;
' LANGUAGE 'plperl';
--
/* Michael A. Nachbaur <mike@nachbaur.com>
* http://nachbaur.com/pgpkey.asc
*/
"Ah, " said Arthur, "this is obviously some strange usage
of the word safe that I wasn't previously aware of. "
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: RFC: i18n2ascii(TEXT) stored procedure
2003-09-25 23:50 RFC: i18n2ascii(TEXT) stored procedure Michael A Nachbaur <mike@nachbaur.com>
@ 2003-09-26 00:06 ` Manuel Sugawara <masm@fciencias.unam.mx>
2003-09-26 00:01 ` Re: RFC: i18n2ascii(TEXT) stored procedure Michael A Nachbaur <mike@nachbaur.com>
2 siblings, 1 reply; 5+ messages in thread
From: Manuel Sugawara @ 2003-09-26 00:06 UTC (permalink / raw)
To: Michael A Nachbaur <mike@nachbaur.com>; +Cc: pgsql-sql
Michael A Nachbaur <mike@nachbaur.com> writes:
> b) is there a better and/or faster way of implementing this? I
> don't want searches to bog down (at least too badly) as a result of
> this.
Use to_ascii(text),
masm=# select to_ascii('áéíóú');
to_ascii
----------
aeiou
(1 row)
Regards,
Manuel.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: RFC: i18n2ascii(TEXT) stored procedure
2003-09-25 23:50 RFC: i18n2ascii(TEXT) stored procedure Michael A Nachbaur <mike@nachbaur.com>
2003-09-26 00:06 ` Re: RFC: i18n2ascii(TEXT) stored procedure Manuel Sugawara <masm@fciencias.unam.mx>
@ 2003-09-26 00:01 ` Michael A Nachbaur <mike@nachbaur.com>
0 siblings, 0 replies; 5+ messages in thread
From: Michael A Nachbaur @ 2003-09-26 00:01 UTC (permalink / raw)
To: Manuel Sugawara <masm@fciencias.unam.mx>; +Cc: pgsql-sql
On Thursday 25 September 2003 05:06 pm, Manuel Sugawara wrote:
> Michael A Nachbaur <mike@nachbaur.com> writes:
> > b) is there a better and/or faster way of implementing this? I
> > don't want searches to bog down (at least too badly) as a result of
> > this.
>
> Use to_ascii(text),
[snip]
D'oh! I guess thats what I get for not RTFM. :-)
--
/* Michael A. Nachbaur <mike@nachbaur.com>
* http://nachbaur.com/pgpkey.asc
*/
"Oh no, not again."
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: RFC: i18n2ascii(TEXT) stored procedure
2003-09-25 23:50 RFC: i18n2ascii(TEXT) stored procedure Michael A Nachbaur <mike@nachbaur.com>
@ 2003-09-26 06:30 ` Peter Eisentraut <peter_e@gmx.net>
2 siblings, 0 replies; 5+ messages in thread
From: Peter Eisentraut @ 2003-09-26 06:30 UTC (permalink / raw)
To: Michael A Nachbaur <mike@nachbaur.com>; +Cc: pgsql-sql
Michael A Nachbaur writes:
> a) am I missing any characters that need to be converted?
In Unicode, any character can be dynamically combined with any number of
accent characters, so an enumerated list will never do.
--
Peter Eisentraut peter_e@gmx.net
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: RFC: i18n2ascii(TEXT) stored procedure
2003-09-25 23:50 RFC: i18n2ascii(TEXT) stored procedure Michael A Nachbaur <mike@nachbaur.com>
@ 2003-09-26 14:10 ` scott.marlowe <scott.marlowe@ihs.com>
2 siblings, 0 replies; 5+ messages in thread
From: scott.marlowe @ 2003-09-26 14:10 UTC (permalink / raw)
To: Michael A Nachbaur <mike@nachbaur.com>; +Cc: pgsql-sql
On Thu, 25 Sep 2003, Michael A Nachbaur wrote:
> I've created the following stored procedure to allow me to do
> international-insensitive text searches, e.g. a search for "Resume" would
> match the text "Résumé".
>
> I wanted to know:
>
> a) am I missing any characters that need to be converted? My first (and only
> language) is English, so I'm in the dark when that is concerned;
> b) is there a better and/or faster way of implementing this? I don't want
> searches to bog down (at least too badly) as a result of this.
>
> CREATE OR REPLACE FUNCTION i18n2ascii (TEXT) RETURNS TEXT AS '
> my ($source) = @_;
> $source =~
> tr/áàâäéèêëíìîïóòôöúùûüÁÀÂÄÉÈÊËÍÌÎÏÓÒÔÖÚÙÛÜ/aaaaeeeeiiiioooouuuuAAAAEEEEIIIIOOOOUUUU/;
> return $source;
> ' LANGUAGE 'plperl';
You could probably accomplish the same thing without using perl via the
built in function translate(). Look in the functions-string.html in the
7.3.x documentation.
Also, the regex version of substring() is quite powerful.
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2003-09-26 14:10 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-09-25 23:50 RFC: i18n2ascii(TEXT) stored procedure Michael A Nachbaur <mike@nachbaur.com>
2003-09-26 00:06 ` Manuel Sugawara <masm@fciencias.unam.mx>
2003-09-26 00:01 ` Michael A Nachbaur <mike@nachbaur.com>
2003-09-26 06:30 ` Peter Eisentraut <peter_e@gmx.net>
2003-09-26 14:10 ` scott.marlowe <scott.marlowe@ihs.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox