3 added 120 characters in body
source | link

I'm using PostgreSQL 9.6 on Linux. I got an error when I do a test on chr() function.

postgres=# select chr(1199111);
ERROR:  requested character too large for encoding: 1199111
postgres=# select chr(55296);
ERROR:  requested character not valid for encoding: 55296
postgres=# select chr(100000);
 chr
-----
 𘚠
(1 row)

Here, as you can see with value 100k it worked (didn't raise error), however others didn't. I'm curious about that. Could someone please explain to me why ?

I attach test script

do
$$
declare 
str text ;
begin
for i in 1..1200000
loop
begin
select chr(i) into str;
exception when others then raise notice '=> i: %     => str: %', i , str ;
#exit; -- you can uncomment this star key
end ;
end loop;
end 
$$ ;

UPDATED

postgres=# show server_encoding;
 server_encoding
-----------------
 UTF8
(1 row)

I'm using PostgreSQL 9.6 on Linux. I got an error when I do a test on chr() function.

postgres=# select chr(1199111);
ERROR:  requested character too large for encoding: 1199111
postgres=# select chr(55296);
ERROR:  requested character not valid for encoding: 55296
postgres=# select chr(100000);
 chr
-----
 𘚠
(1 row)

Here, as you can see with value 100k it worked (didn't raise error), however others didn't. I'm curious about that. Could someone please explain to me why ?

I attach test script

do
$$
declare 
str text ;
begin
for i in 1..1200000
loop
begin
select chr(i) into str;
exception when others then raise notice '=> i: %     => str: %', i , str ;
#exit; -- you can uncomment this star key
end ;
end loop;
end 
$$ ;

I'm using PostgreSQL 9.6 on Linux. I got an error when I do a test on chr() function.

postgres=# select chr(1199111);
ERROR:  requested character too large for encoding: 1199111
postgres=# select chr(55296);
ERROR:  requested character not valid for encoding: 55296
postgres=# select chr(100000);
 chr
-----
 𘚠
(1 row)

Here, as you can see with value 100k it worked (didn't raise error), however others didn't. I'm curious about that. Could someone please explain to me why ?

I attach test script

do
$$
declare 
str text ;
begin
for i in 1..1200000
loop
begin
select chr(i) into str;
exception when others then raise notice '=> i: %     => str: %', i , str ;
#exit; -- you can uncomment this star key
end ;
end loop;
end 
$$ ;

UPDATED

postgres=# show server_encoding;
 server_encoding
-----------------
 UTF8
(1 row)
2 add encoding tag
| link
1
source | link

ERROR: requested character too large for encoding

I'm using PostgreSQL 9.6 on Linux. I got an error when I do a test on chr() function.

postgres=# select chr(1199111);
ERROR:  requested character too large for encoding: 1199111
postgres=# select chr(55296);
ERROR:  requested character not valid for encoding: 55296
postgres=# select chr(100000);
 chr
-----
 𘚠
(1 row)

Here, as you can see with value 100k it worked (didn't raise error), however others didn't. I'm curious about that. Could someone please explain to me why ?

I attach test script

do
$$
declare 
str text ;
begin
for i in 1..1200000
loop
begin
select chr(i) into str;
exception when others then raise notice '=> i: %     => str: %', i , str ;
#exit; -- you can uncomment this star key
end ;
end loop;
end 
$$ ;