Re: Unicode normalization - Mailing list pgsql-general

From Andreas Kalsch
Subject Re: Unicode normalization
Date
Msg-id 4AB2327F.10707@gmx.de
Whole thread Raw
In response to Re: Unicode normalization  (Alvaro Herrera <alvherre@commandprompt.com>)
List 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 by date:

Previous
From: Sam Mason
Date:
Subject: Re: Unicode normalization
Next
From: el dorado
Date:
Subject: Re[2]: Problems with pg_dump for PG8.4 for WinXP (MinGW build)