是否可以解释在PostgreSQL表中存储的类似C的逃生字符?

发布于 2025-01-19 23:22:38 字数 747 浏览 0 评论 0 原文

基于 htttps:htttps:// www。 postgresql.org/docs/current/sql-syntax-lexical.html#sql-syntax-snntax-snrings-escape ,我可以做到:

SELECT E'Test:\t\u00e1\u00e4\u00e9' as col;
-- Result (\t is interpreted tab character without problem, unicodes too):
     col
-------------
 Test:   áäé

但是我想做些不同的事情,我无法解决它:

SELECT do_something_with_text(col)
FROM (SELECT 'Test:\t\u00e1\u00e4\u00e9' as col) as t;

do_something_with_text(text)函数在哪里解释逃脱的unicode和众所周知的代码,并返回与第一个结果完全相同的结果。

有可能以简单的方式吗?我不想用e''版本替换所有逃脱字符。

问候

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

铜锣湾横着走 2025-01-26 23:22:38

在链接带有C风格的Escapes 的字符串常数您提供的:

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:   áäé

这曾经是Postgres 9.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文