'Is it possible to interpret C-like escape characters stored in postgresql table's column?
Based on https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE , I can do it:
SELECT E'Test:\t\u00e1\u00e4\u00e9' as col;
-- Result (\t is interpreted tab character without problem, unicodes too):
col
-------------
Test: áäé
but I'd like to do something different and I can't solve it:
SELECT do_something_with_text(col)
FROM (SELECT 'Test:\t\u00e1\u00e4\u00e9' as col) as t;
where do_something_with_text(text) function will interpret escape Unicode and well-known codes and returns exactly the same result as first one.
Is it possible in easy way? I don't want to replace all escaping characters by E'' versions.
Regards
Solution 1:[1]
Per the Caution block at the link String Constants with C-Style Escapes you provided:
show standard_conforming_strings ;
standard_conforming_strings
-----------------------------
on
show escape_string_warning ;
escape_string_warning
-----------------------
on
set standard_conforming_strings = off;
set escape_string_warning = off;
SELECT 'Test:\t\u00e1\u00e4\u00e9' as col;
col
-------------
Test: áäé
This used to be the default behavior in Postgres 9.1-. I would read the Caution and the contents of the links within in it to get a idea of what rolling back to previous behavior means.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
