C11: should we use char32_t for unicode code points?
Jeff Davis <pgsql@j-davis.com>
From: Jeff Davis <pgsql@j-davis.com>
To: pgsql-hackers@postgresql.org
Date: 2025-10-23T18:15:54Z
Lists: pgsql-hackers
Attachments
- v1-0001-Use-C11-char32_t-for-Unicode-code-points.patch (text/x-patch) patch v1-0001
Now that we're using C11, should we use char32_t for unicode code points? Right now, we use pg_wchar for two purposes: 1. to abstract away some problems with wchar_t on platforms where it's 16 bits; and 2. hold unicode code point values In UTF8, they are are equivalent and can be freely cast back and forth, but not necessarily in other encodings. That can be confusing in some contexts. Attached is a patch to use char32_t for the second purpose. Both are equivalent to uint32, so there's no functional change and no actual typechecking, it's just for readability. Is this helpful, or needless code churn? Regards, Jeff Davis
Commits
-
Use C11 char16_t and char32_t for Unicode code points.
- 3853a6956c3e 19 (unreleased) landed
-
Move comment about casts from pg_wchar.
- 4da12e9e2e3c 19 (unreleased) landed
-
Comment typo fixes: pg_wchar_t should be pg_wchar.
- 371a302eecdc 19 (unreleased) landed