locale and spanish acute

Started by Martín Marquésover 24 years ago9 messagesgeneral
Jump to latest
#1Martín Marqués
martin@bugs.unl.edu.ar

I'm doing some searches with LIKE and have a problem with words with acute
vocals. I would like m�s to be treated the same way as mas, and vice-verse.

Is this because I don't have the locale set correctly?

Saludos... ;-)

--
Porqu� usar una base de datos relacional cualquiera,
si pod�s usar PostgreSQL?
-----------------------------------------------------------------
Mart�n Marqu�s | mmarques@unl.edu.ar
Programador, Administrador, DBA | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------

#2Martín Marqués
martin@bugs.unl.edu.ar
In reply to: Martín Marqués (#1)
Re: locale and spanish acute

On Mi� 12 Sep 2001 20:10, you wrote:

Mart�n Marqu�s writes:

I'm doing some searches with LIKE and have a problem with words with
acute vocals. I would like m�s to be treated the same way as mas, and
vice-verse.

Is this because I don't have the locale set correctly?

No, it's because it doesn't work that way. What you probably want to do
is "accent-fold" your strings before sending them through pattern
matching.

What does "accent-fold" mean?

--
Porqu� usar una base de datos relacional cualquiera,
si pod�s usar PostgreSQL?
-----------------------------------------------------------------
Mart�n Marqu�s | mmarques@unl.edu.ar
Programador, Administrador, DBA | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------

#3Peter Eisentraut
peter_e@gmx.net
In reply to: Martín Marqués (#1)
Re: locale and spanish acute

Mart�n Marqu�s writes:

I'm doing some searches with LIKE and have a problem with words with acute
vocals. I would like m�s to be treated the same way as mas, and vice-verse.

Is this because I don't have the locale set correctly?

No, it's because it doesn't work that way. What you probably want to do
is "accent-fold" your strings before sending them through pattern
matching.

--
Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter

#4Peter Eisentraut
peter_e@gmx.net
In reply to: Martín Marqués (#2)
Re: locale and spanish acute

Mart�n Marqu�s writes:

On Mi� 12 Sep 2001 20:10, you wrote:

Mart�n Marqu�s writes:

I'm doing some searches with LIKE and have a problem with words with
acute vocals. I would like m�s to be treated the same way as mas, and
vice-verse.

Is this because I don't have the locale set correctly?

No, it's because it doesn't work that way. What you probably want to do
is "accent-fold" your strings before sending them through pattern
matching.

What does "accent-fold" mean?

Convert all accented characters to some other characters in a way that is
meaningful to you.

--
Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter

#5Martín Marqués
martin@bugs.unl.edu.ar
In reply to: Peter Eisentraut (#4)
Re: locale and spanish acute

On Mi� 12 Sep 2001 21:52, Peter Eisentraut wrote:

Mart�n Marqu�s writes:

What does "accent-fold" mean?

Convert all accented characters to some other characters in a way that is
meaningful to you.

OK, I think I got what you told me.
lets see... I have this query:

select count(*) from tab1 where col1 LIKE '%mas%'

but I would like it to catch rows with "m�s" also.

The only thing I can think of is makeing a function that applied to col1
would give me col1 but without accents. Say the function is called
no_accents, so:

no_accents(m�s)=mas

Now, the problem is that I have little idea on making such a function. Is it
very difficult?

Saludos... :-)

--
Porqu� usar una base de datos relacional cualquiera,
si pod�s usar PostgreSQL?
-----------------------------------------------------------------
Mart�n Marqu�s | mmarques@unl.edu.ar
Programador, Administrador, DBA | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------

#6Peter Eisentraut
peter_e@gmx.net
In reply to: Martín Marqués (#5)
Re: locale and spanish acute

Mart�n Marqu�s writes:

select count(*) from tab1 where col1 LIKE '%mas%'

but I would like it to catch rows with "m�s" also.

The only thing I can think of is makeing a function that applied to col1
would give me col1 but without accents. Say the function is called
no_accents, so:

no_accents(m�s)=mas

Now, the problem is that I have little idea on making such a function. Is it
very difficult?

CREATE FUNCTION no_accents(text) RETURNS text AS '
my $arg = $_[0];
$arg =~ tr/�������/aeeinou/;
return $arg;
' LANGUAGE 'plperl';

Something similar should be possible in PL/Tcl if you prefer that. Or you
bother with C and run a simple loop over the text string.

--
Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter

#7tony
tony@animaproductions.com
In reply to: Peter Eisentraut (#6)
Re: locale and spanish acute

On Fri, 2001-09-14 at 15:49, Peter Eisentraut wrote:

Martín Marqués writes:

select count(*) from tab1 where col1 LIKE '%mas%'

but I would like it to catch rows with "más" also.

select count(*) from tab1 where col1 ILIKE to_ascii($1)

works for me.

The variable is passed via .jsp

Cheers

Tony Grant

--
RedHat Linux on Sony Vaio C1XD/S
http://www.animaproductions.com/linux2.html
Macromedia UltraDev with PostgreSQL
http://www.animaproductions.com/ultra.html

#8Martín Marqués
martin@bugs.unl.edu.ar
In reply to: tony (#7)
Re: locale and spanish acute

On Lun 17 Sep 2001 04:31, Tony Grant wrote:

On Fri, 2001-09-14 at 15:49, Peter Eisentraut wrote:

Martín Marqués writes:

select count(*) from tab1 where col1 LIKE '%mas%'

but I would like it to catch rows with "más" also.

select count(*) from tab1 where col1 ILIKE to_ascii($1)

works for me.

But I want it to work with más too. For that I would need to change that
query for this one:

select count(*) from tab1 where to_ascii(col1) ILIKE to_ascii($1)

Right?

Saludos... :-)

--
Porqué usar una base de datos relacional cualquiera,
si podés usar PostgreSQL?
-----------------------------------------------------------------
Martín Marqués | mmarques@unl.edu.ar
Programador, Administrador, DBA | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------

#9tony
tony@animaproductions.com
In reply to: Martín Marqués (#8)
Re: locale and spanish acute

On Mon, 2001-09-17 at 22:49, Martín Marqués wrote:

But I want it to work with más too. For that I would need to change that
query for this one:

select count(*) from tab1 where to_ascii(col1) ILIKE to_ascii($1)

Right?

Right that will work because the content and the request is changed.

Cheers

Tony

--
RedHat Linux on Sony Vaio C1XD/S
http://www.animaproductions.com/linux2.html
Macromedia UltraDev with PostgreSQL
http://www.animaproductions.com/ultra.html