diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 6765b0d584..989344c98c 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -1752,6 +1752,9 @@
decode
+
+ base64 encoding
+ decode(stringtext,
formattext)
@@ -1769,16 +1772,25 @@
encode
+
+ base64 encoding
+
+
+ hex encoding
+
+
+ escape encoding
+ encode(databytea,
formattext)text
Encode binary data into a textual representation. Supported
- formats are: base64, hex, escape.
- escape converts zero bytes and high-bit-set bytes to
- octal sequences (\nnn) and
- doubles backslashes.
+ formats are:
+ base64,
+ hex,
+ escape.
encode('123\000\001', 'base64')MTIzAAE=
@@ -2365,6 +2377,90 @@
format treats a NULL as a zero-element array.
+
+ encode
+
+
+ decode
+
+
+ base64 encoding
+
+
+ hex encoding
+
+
+ escape encoding
+
+
+
+ The string and the binary encode
+ and decode functions support the following
+ encodings:
+
+
+
+ base64
+
+
+ The base64 encoding is that
+ of RFC
+ 2045 section 6.8. As per the RFC, encoded lines are
+ broken at 76 characters. However instead of the MIME CRLF
+ end-of-line marker, only a newline is used for end-of-line.
+
+
+ The carriage-return, newline, space, and tab characters are
+ ignored by decode. Otherwise, an error is
+ raised when decode is supplied invalid
+ base64 data — including when trailing padding is incorrect.
+
+
+
+
+
+ hex
+
+
+ hex represents each 4 bits of data as a single
+ hexadecimal digit, 0
+ through f. Encoding outputs
+ the a-f hex digits in lower
+ case. Because the smallest unit of data is 8 bits there are
+ always an even number of characters returned
+ by encode.
+
+
+ The decode function
+ accepts a-f characters in
+ either upper or lower case. An error is raised
+ when decode is supplied invalid hex data
+ — including when given an odd number of characters.
+
+
+
+
+
+ escape
+
+
+ escape converts zero bytes and high-bit-set
+ bytes to octal sequences
+ (\nnn) and doubles
+ backslashes. Encoding always produces 4 characters for each
+ high-bit-set input byte.
+
+
+ The decode function accepts fewer than three
+ octal digits after a \ character. An error is
+ raised when decode is supplied a
+ single \ not followed by an octal digit.
+
+
+
+
+
+
See also the aggregate function string_agg in
.
@@ -3577,16 +3673,25 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three');
encode
+
+ base64 encoding
+
+
+ hex encoding
+
+
+ escape encoding
+ encode(databytea,
formattext)text
Encode binary data into a textual representation. Supported
- formats are: base64, hex, escape.
- escape converts zero bytes and high-bit-set bytes to
- octal sequences (\nnn) and
- doubles backslashes.
+ formats are:
+ base64,
+ hex,
+ escape.
encode('123\000456'::bytea, 'escape')123\000456