Re: proposal: unescape_text function
Pavel Stehule <pavel.stehule@gmail.com>
From: Pavel Stehule <pavel.stehule@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2020-06-23T09:51:40Z
Lists: pgsql-hackers
Attachments
- unicode_unescape.patch (text/x-patch) patch
po 22. 6. 2020 v 5:48 odesílatel Pavel Stehule <pavel.stehule@gmail.com>
napsal:
> Hi
>
> There is one user request for unescape function in core.
>
>
> https://stackoverflow.com/questions/20124393/convert-escaped-unicode-character-back-to-actual-character-in-postgresql/20125412?noredirect=1#comment110502526_20125412
>
> This request is about possibility that we do with string literal via
> functional interface instead string literals only
>
> I wrote plpgsql function, but built in function can be simpler:
>
> CREATE OR REPLACE FUNCTION public.unescape(text, text)
> RETURNS text
> LANGUAGE plpgsql
> AS $function$
> DECLARE result text;
> BEGIN
> EXECUTE format('SELECT U&%s UESCAPE %s',
> quote_literal(replace($1, '\u','^')),
> quote_literal($2)) INTO result;
> RETURN result;
> END;
> $function$
>
> postgres=# select unescape('Odpov\u011Bdn\u00E1 osoba','^');
> unescape -----------------
> Odpovědná osoba(1 row)
>
> What do you think about this?
>
I changed the name to more accurately "unicode_unescape". Patch is assigned
Regards
Pavel
> Regards
>
> Pavel
>
Commits
-
Add unistr function
- f37fec837ce8 14.0 landed