PostgreSQL and GB18030-2022 Support
PostgreSQL supports GB18030 as a client-side encoding. A client-side encoding means you can set the encoding from a client application such as psql with:
psql=# set client_encoding to GB18030
This tells the PostgreSQL backend that the client will send SQL statements encoded in GB18030. When the backend receives a statement, it converts the GB18030 byte stream into UTF-8 (the default server-side encoding), and then passes it to exec_simple_query() for execution.
GB18030 Versions
GB18030 has multiple versions. Since August 1, 2023, China has mandated the GB18030-2022 standard. However, as of the time of writing, PostgreSQL still supports only GB18030-2000.
GB18030-2022 is not fully backward-compatible with GB18030-2000 — some glyphs map to different Unicode code points.
For example, the GB18030 glyph ︐ has the GB18030 code 0xA6D9. If we convert it to UTF-8 using psql:
mydb=# SELECT encode(convert_from(decode('a6d9', 'hex'), 'GB18030')::bytea, 'hex');
encode
--------
ee9e8d
(1 row)
PostgreSQL converts it to UTF-8 code 0xEE9E8D.
However, if we use a web tool like qqxiuzi.cn to look up the glyph in multiple encodings, we find that the corresponding UTF-8 code should be 0xEFB890 — a mismatch.

This difference occurs because the web tool follows GB18030-2022, while PostgreSQL still uses GB18030-2000.
Moving Toward GB18030-2022
To make PostgreSQL compliant with GB18030-2022, HighGo has submitted a patch: https://commitfest.postgresql.org/patch/5954/. Once this patch is merged, PostgreSQL will support the GB18030-2022 standard.
EDIT:The patch has been merged into PG master branch on Sep. 24th 2025, will be included in release 19.
Changes Introduced by GB18030-2022
In summary, GB18030-2022 introduces three key changes compared to the previous 2000 and 2005 standards:
- Adds 66 new ideographs
- Removes 9 ideographs that are no longer required; applications can choose whether to retain them
- Alters the Unicode mapping for 18 ideographs, which causes backward compatibility issues
Below is the list of the 18 ideographs affected:
| Ideograph | GB18030 code | 2000 mapped unicode | 2022 mapped unicode |
| ︐ | U+E78D | U+E78D | U+FE10 |
| ︒ | 0xA6DA | U+E78E | U+FE12 |
| ︑ | 0xA6DB | U+E78F | U+FE11 |
| ︓ | 0xA6DC | U+E790 | U+FE13 |
| ︔ | 0xA6DD | U+E791 | U+FE14 |
| ︕ | 0xA6DE | U+E792 | U+FE15 |
| ︖ | 0xA6DF | U+E793 | U+FE16 |
| ︗ | 0xA6EC | U+E794 | U+FE17 |
| ︘ | 0xA6ED | U+E795 | U+FE18 |
| ︙ | 0xA6F3 | U+E796 | U+FE19 |
| 龴 | 0xFE59 | U+E81E | U+9FB4 |
| 龵 | 0xFE61 | U+E826 | U+9FB5 |
| 龶 | 0xFE66 | U+E82B | U+9FB6 |
| 龷 | 0xFE67 | U+E82C | U+9FB7 |
| 龸 | 0xFE6D | U+E832 | U+9FB8 |
| 龹 | 0xFE7E | U+E843 | U+9FB9 |
| 龺 | 0xFE90 | U+E854 | U+9FBA |
| 龻 | 0xFEA0 | U+E864 | U+9FBB |
These characters are rarely used, so the changes are unlikely to have significant impact on most databases.
For more detailed information, see this excellent reference: The GB 18030-2022 Standard.

Recent Comments