Обсуждение: proposal: to_ascii(bytea)

Поиск
Список
Период
Сортировка

proposal: to_ascii(bytea)

От
"Pavel Stehule"
Дата:
Hello,

Changes related to convert* functions in postgresql 8.3 has impact on
to_ascii function.

Before 8.3 I could do:
postgres=#  select to_ascii(convert('Příliš žlutý kůň' using
utf8_to_iso_8859_2),'latin2');    to_ascii
------------------Prilis zluty kun
(1 row)

but convert_to function return bytea now, and I can't to call it
without unwanted changes in content of translated text.

postgres=# SELECT to_ascii(convert_to('Příliš žlutý kůň',
'latin2')::text,'latin2');              to_ascii
---------------------------------------P\370\355li\271 \276lut\375 k\371\362
(1 row)

ugly hack for it:
postgres=# create function to_ascii(bytea, name) returns text as
'to_ascii_encname' language internal;
CREATE FUNCTION
postgres=#
postgres=# SELECT to_ascii(convert_to('Příliš žlutý kůň', 'latin2'),'latin2');    to_ascii
------------------Prilis zluty kun
(1 row)

Regards
Pavel Stehule

Re: proposal: to_ascii(bytea)

От
Tom Lane
Дата:
"Pavel Stehule" <pavel.stehule@gmail.com> writes:
> Changes related to convert* functions in postgresql 8.3 has impact on
> to_ascii function.

ISTM to_ascii has a completely bogus API anyway.  What is it doing
taking an encoding name as an argument?  It should just assume the
input text is in the database encoding.

The real fix that's needed there is to improve the set of encodings
it can deal with ...
        regards, tom lane