Re: proposal: unescape_text function

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: unescape_text function
Date: 2020-06-23 09:51:40
Message-ID: CAFj8pRBwrnotQzzVmG8s1i+cZ=h0FNv08Q=OcG+9NPMy7jkZ6g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

po 22. 6. 2020 v 5:48 odesílatel Pavel Stehule <pavel(dot)stehule(at)gmail(dot)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
>

Attachment Content-Type Size
unicode_unescape.patch text/x-patch 10.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2020-06-23 09:56:58 Re: EXPLAIN: Non-parallel ancestor plan nodes exclude parallel worker instrumentation
Previous Message Kyotaro Horiguchi 2020-06-23 09:42:10 Re: Assertion failure in pg_copy_logical_replication_slot()