]> git.8kb.co.uk Git - postgresql/encoding_woes/blob - codepage_850.sql
Added sql functions to check if we really need to do any conversion.
[postgresql/encoding_woes] / codepage_850.sql
1 DROP FUNCTION IF EXISTS public.decode_cp850(text);
2 CREATE OR REPLACE FUNCTION public.decode_cp850(text)
3 RETURNS text AS
4 $BODY$
5     SELECT CASE WHEN $1 ~ '[^\x01-\x7F]' THEN cp850_to_utf8($1) ELSE $1 END;        
6 $BODY$
7 LANGUAGE sql IMMUTABLE;
8
9 --
10
11 DROP FUNCTION IF EXISTS public.encode_cp850(text);
12 CREATE OR REPLACE FUNCTION public.encode_cp850(text)
13 RETURNS text AS
14 $BODY$
15     SELECT CASE WHEN $1 ~ '[^\x01-\x7F]' THEN utf8_to_cp850($1) ELSE $1 END;        
16 $BODY$
17 LANGUAGE sql IMMUTABLE;