Search Postgresql Archives

Re: Unicode normalization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux