Re: Unexpected behaviour of encode()

Поиск
Список
Период
Сортировка
От Jasen Betts
Тема Re: Unexpected behaviour of encode()
Дата
Msg-id kj2e56$u3a$1@gonzo.reversiblemaps.ath.cx
обсуждение исходный текст
Ответ на Unexpected behaviour of encode()  (Bill Moran <wmoran@potentialtech.com>)
Ответы Re: Unexpected behaviour of encode()
Список pgsql-general
On 2013-03-26, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> The manual says that 'escape' encoding "merely outputs null bytes as
> \000 and doubles backslashes".

> (Having said that, I wonder though if "escape" doesn't need more
> thought.  The output is only valid text in SQL_ASCII or single-byte
> encodings, otherwise there's risk of encoding violations.)

it does that too, since as long as I can remember.
I used decode-hex here so it'll work on older version of pg.

select encode(decode('ee5c2700aa','hex'),'escape');
    encode
--------------------
 \356\\'\000\252

to see the slashes doubled you need to run it through quote-literal

select quote_literal(encode(decode('ee5c2700aa','hex'),'escape'));
      quote_literal
--------------------------
 E'\\356\\\\''\\000\\252'

--
⚂⚃ 100% natural

В списке pgsql-general по дате отправления:

Предыдущее
От: Gavin Flower
Дата:
Сообщение: Re: Money casting too liberal?
Следующее
От: Jasen Betts
Дата:
Сообщение: Re: Understanding behavior of SELECT with multiple unnested columns