ASCIISTR
最近更新时间: 2025-02-18 16:02:00
ASCIISTR函数,参数是一个字符串,如果这个字符在ASCII码表中有,则转成ASCII表中的字符。如果没有,则转成\xxxx格式,xxxx是UTF8的编码。
create or replace function asciistr(str text) returns text as
$$
declare
mid text;
res text:='';
begin
foreach mid in array regexp_split_to_array(str, '')
loop
if ascii(mid)<256 then
res := res || mid;
else
res := res || convert_to(mid,'UTF8')::text;
end if;
end loop;
return res;
end;
$$
language plpgsql strict;