Re: Hex escapes in strings only support ASCII range

From: Sven Klemm <sven(at)timescale(dot)com>
To: Vilem Benjamin Liepelt <vileml(at)sqreamtech(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Hex escapes in strings only support ASCII range
Date: 2021-03-08 14:25:15
Message-ID: CAMCrgp0yOayemnBNWjed6DvfW8H555PDs5Za80wnm-E2MW3_YA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Mar 8, 2021 at 2:43 PM Vilem Benjamin Liepelt
<vileml(at)sqreamtech(dot)com> wrote:
>
> Escaped strings [1] fail on hex values greater than \x7f with a factually incorrect error message:
>
> $ psql --command "select E'\x80';"
> ERROR: invalid byte sequence for encoding "UTF8": 0x80
>
> $ psql --version
> psql (PostgreSQL) 13.1
>
> I was able to reproduce this bug on psql 10.
>
> Workaround:
>
> $ psql --command "select E'\u0080';"
> ?column?
> ----------
> \u0080
> (1 row)

0x80 is not equivalent to \u0080 in UTF8. You may use hex values
greater than 0x7F but you still have to produce valid byte sequences
for your target encoding or switch to an encoding that does not
validate those sequences.

postgres=# select E'\xc2\x80';

?column?
----------
\u0080
(1 row)

--
Regards, Sven Klemm

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Vilem Benjamin Liepelt 2021-03-08 14:53:49 Re: Hex escapes in strings only support ASCII range
Previous Message Euler Taveira 2021-03-08 12:40:04 Re: BUG #16915: use psql have error "could not change directory to "/root": Permission denied"