diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2021-03-28 08:16:15 +0200 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2021-03-29 11:56:53 +0200 |
commit | f37fec837ce8bf7af408ba66d32099e5a0182402 (patch) | |
tree | cfbdeae1f431dab8803c9d2cac91e4d71a5e1cad /doc/src | |
parent | ebedd0c78fc51c293abe56e99a18c67af14da0c9 (diff) | |
download | postgresql-f37fec837ce8bf7af408ba66d32099e5a0182402.tar.gz postgresql-f37fec837ce8bf7af408ba66d32099e5a0182402.zip |
Add unistr function
This allows decoding a string with Unicode escape sequences. It is
similar to Unicode escape strings, but offers some more flexibility.
Author: Pavel Stehule <pavel.stehule@gmail.com>
Reviewed-by: Asif Rehman <asifr.rehman@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAFj8pRA5GnKT+gDVwbVRH2ep451H_myBt+NTz8RkYUARE9+qOQ@mail.gmail.com
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/func.sgml | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 19285ae1360..fbf6062d0a8 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -3551,6 +3551,52 @@ repeat('Pg', 4) <returnvalue>PgPgPgPg</returnvalue> </para></entry> </row> + <row> + <entry role="func_table_entry"><para role="func_signature"> + <indexterm> + <primary>unistr</primary> + </indexterm> + <function>unistr</function> ( <type>text</type> ) + <returnvalue>text</returnvalue> + </para> + <para> + Evaluate escaped Unicode characters in argument. Unicode characters + can be specified as + <literal>\<replaceable>XXXX</replaceable></literal> (4 hexadecimal + digits), <literal>\+<replaceable>XXXXXX</replaceable></literal> (6 + hexadecimal digits), + <literal>\u<replaceable>XXXX</replaceable></literal> (4 hexadecimal + digits), or <literal>\U<replaceable>XXXXXXXX</replaceable></literal> + (8 hexadecimal digits). To specify a backslash, write two + backslashes. All other characters are taken literally. + </para> + + <para> + If the server encoding is not UTF-8, the Unicode code point identified + by one of these escape sequences is converted to the actual server + encoding; an error is reported if that's not possible. + </para> + + <para> + This function provides a (non-standard) alternative to string + constants with Unicode escapes (see <xref + linkend="sql-syntax-strings-uescape"/>). + </para> + + <para> + <literal>unistr('\0441\043B\043E\043D')</literal> + <returnvalue>слон</returnvalue> + </para> + <para> + <literal>unistr('d\0061t\+000061')</literal> + <returnvalue>data</returnvalue> + </para> + <para> + <literal>unistr('d\u0061t\U00000061')</literal> + <returnvalue>data</returnvalue> + </para></entry> + </row> + </tbody> </tgroup> </table> |