debugsqlMinor
ERROR: requested character too large for encoding
Viewed 0 times
errorcharactertoolargeforencodingrequested
Problem
I'm using PostgreSQL 9.6 on Linux.
I got an error when I do a test on chr() function.
Here, as you can see with value
I attach test script
UPDATED
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)Solution
Because it didn't raise an error, doesn't mean it worked. None of these work, but only one of them is so absurd as to make
Unicode only supports 1,111,998: 17 planes × 65,536 characters per plane - 2048 surrogates - 66 noncharacters. See this answer for more information. 1.11 Million code points, is far less than 1.19 Million code points.
chr() explode.- 100000 (
186A0) maps to the Supplementary Multilingual Plane, but there is nothing there (yet).
- 55296 (
U+D800) maps to the Basic Multilingual Plane, but nothing is there (yet).
- 1199111 (
U+124C07) is not even valid, it maps to a plane so high that Unicode doesn't even support it.
Unicode only supports 1,111,998: 17 planes × 65,536 characters per plane - 2048 surrogates - 66 noncharacters. See this answer for more information. 1.11 Million code points, is far less than 1.19 Million code points.
Context
StackExchange Database Administrators Q#164641, answer score: 4
Revisions (0)
No revisions yet.