Encoding problem

Started by Arnaud Lesauvageover 19 years ago3 messagesgeneral
Jump to latest
#1Arnaud Lesauvage
thewild@freesurf.fr

Hi List !

I am trying to remove accents from a string. I found a nice
solution for this on postgresqlfr, using the to_ascii()
function.

Now, the problem I have is :

mydb=# SELECT to_ascii(convert('abcdef', 'LATIN9'));
ERROR: encoding conversion from UTF8 to ASCII not supported

Why is the conversion to LATIN9 not working as expected ?
My database's encoding is UTF8.

Furthermore, in PgAdmin, running SELECT convert(somestring,
'LATIN9'); returns empty strings whenever somestring
contains special (accentued, in my case) characters.
SELECT Length(convert(somestring, 'LATIN9')); looks OK though !

I think my misunderstanding of encoding is driving me crazy...
Could anyone help me on this ?

Thanks !
--
Arnaud

#2Albe Laurenz
all@adv.magwien.gv.at
In reply to: Arnaud Lesauvage (#1)
Re: Encoding problem

I am trying to remove accents from a string. I found a nice
solution for this on postgresqlfr, using the to_ascii()
function.

Now, the problem I have is :

mydb=# SELECT to_ascii(convert('abcdef', 'LATIN9'));
ERROR: encoding conversion from UTF8 to ASCII not supported

Why is the conversion to LATIN9 not working as expected ?
My database's encoding is UTF8.

Maybe you actually want to

test=> select to_ascii(convert('ábcdêf', 'LATIN9'), 'LATIN9');
to_ascii
----------
abcdef
(1 row)

Yours,
Laurenz Albe

#3Arnaud Lesauvage
thewild@freesurf.fr
In reply to: Albe Laurenz (#2)
Re: Encoding problem

Albe Laurenz a �crit :

I am trying to remove accents from a string. I found a nice
solution for this on postgresqlfr, using the to_ascii()
function.

Now, the problem I have is :

mydb=# SELECT to_ascii(convert('abcdef', 'LATIN9'));
ERROR: encoding conversion from UTF8 to ASCII not supported

Why is the conversion to LATIN9 not working as expected ?
My database's encoding is UTF8.

Maybe you actually want to

test=> select to_ascii(convert('�bcd�f', 'LATIN9'), 'LATIN9');
to_ascii
----------
abcdef
(1 row)

Indeed !!!
Thanks a lot !
I suppose that not giving the encoding to 'to_ascii'
defaulted to the database encoding ?
Sorry for this mistake, I did not realize that this setting
existed for the to_ascii function...

Thanks again !

--
Arnaud