Re: Unicode normalization

Поиск
Список
Период
Сортировка
От Andreas Kalsch
Тема Re: Unicode normalization
Дата
Msg-id 4AB2327F.10707@gmx.de
обсуждение исходный текст
Ответ на Re: Unicode normalization  (Alvaro Herrera <alvherre@commandprompt.com>)
Список pgsql-general
My standard encoding is UTF-8 on all levels so I don't need this
high-cost call:

plpy.execute("select setting from pg_settings where name =
'server_encoding'");

Additionally I want to get the original cases.

For this purpose my solution is still fitting to my need. But it is not
the one you have cited below, but:

CREATE OR REPLACE FUNCTION simplify (str text)
RETURNS text
AS $$
import unicodedata

s = unicodedata.normalize('NFKD', str.decode('UTF-8'))
s = ''.join(c for c in s if unicodedata.combining(c) == 0)
return s.encode('UTF-8')
$$ LANGUAGE plpythonu;

Andi

>> 2) Transfering this to PL/Python:
>>
>> CREATE OR REPLACE FUNCTION test (str text)
>>  RETURNS text
>> AS $$
>>    import unicodedata
>>    return unicodedata.normalize('NFKD', str.decode('UTF-8'))
>> $$ LANGUAGE plpythonu;

В списке pgsql-general по дате отправления:

Предыдущее
От: Sam Mason
Дата:
Сообщение: Re: Unicode normalization
Следующее
От: el dorado
Дата:
Сообщение: Re[2]: Problems with pg_dump for PG8.4 for WinXP (MinGW build)