Re: Unicode normalization

Поиск
Список
Период
Сортировка
От Sam Mason
Тема Re: Unicode normalization
Дата
Msg-id 20090916224258.GM5407@samason.me.uk
обсуждение исходный текст
Ответ на Re: Unicode normalization  (Andreas Kalsch <andreaskalsch@gmx.de>)
Ответы Re: Unicode normalization  (Scott Marlowe <scott.marlowe@gmail.com>)
How to simplify unicode strings  (Andreas Kalsch <andreaskalsch@gmx.de>)
Список pgsql-general
On Wed, Sep 16, 2009 at 09:35:02PM +0200, Andreas Kalsch wrote:
> CREATE OR REPLACE FUNCTION test (str text)
>  RETURNS text
> AS $$
>    import unicodedata
>    return unicodedata.normalize('NFKD', str.decode('UTF-8'))
> $$ LANGUAGE plpythonu;

I'd guess you want that to be:

  return unicodedata.normalize('NFKD', str.decode('UTF-8')).encode('UTF-8');

If you're converting from a utf8 encoding, you probably need to go
back again!  This could certainly be made easier though, PG knows what
encoding its strings are stored in, why doesn't it work with unicode
strings by default?

--
  Sam  http://samason.me.uk/

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

Предыдущее
От: Scott Bailey
Дата:
Сообщение: Re: Current state of XML capabilities in PostgreSQL?
Следующее
От: Nathan Widmyer
Дата:
Сообщение: Re: Current state of XML capabilities in PostgreSQL?