← Back to davo.co
aboutsummaryrefslogtreecommitdiffstats
path: root/Unicode-test.c
diff options
context:
space:
mode:
authorDavid Faulkner <[email protected]>2026-08-07 23:40:47 -0500
committerDavid Faulkner <[email protected]>2026-08-07 23:40:47 -0500
commitb3e9e62599532050fc776c5e8f076915b56c2235 (patch)
treeaf252346106a61b18cc6fc6fdbd32e962d096f1c /Unicode-test.c
Import official C23 code examples for Modern C (Jens Gustedt, 2024)HEADupstream-importmain
- Add official C source files, Makefile, c23-fallback.h, and LICENSE - Update README.md with study mirror notice
Diffstat (limited to 'Unicode-test.c')
-rw-r--r--Unicode-test.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/Unicode-test.c b/Unicode-test.c
new file mode 100644
index 0000000..5df61e3
--- /dev/null
+++ b/Unicode-test.c
@@ -0,0 +1,32 @@
+/**
+ ** @file Test handling of different Unicode letters in identifiers.
+ **/
+
+#include "c23-fallback.h"
+
+double Å = 1; // error, Ångström not normalized
+double Å = 2; // ok, A with circle
+double A\u030A = 3; // error, combination not normalized
+double Ω = 1; // error, Ohm not normalized
+double Ω = 2; // ok, Greek capital omega
+double K = 1; // error, Kelvin not normalized
+double K = 2;
+double fi = 1; // valid, fi does not decompose into f and i
+double fi = 2; // valid, different identifier
+typedef double ℝ; // valid
+typedef unsigned long long ℕ; // valid
+#define ℜ(Z) real(Z) // valid
+#define ℑ(Z) imag(Z) // valid
+ℕ №; // error: Numero sign is not a letter
+ℕ ℓ; // valid, ell sign is a letter
+double ʃ(double a, double b, double φ(double)); // IPA is also acceptable
+typedef double 각; // valid, Hangul generally maps to itself
+각 α = 1;
+enum : bool { 응 = true, wɛ = true, };
+char const 얜읐[] = "얜읐";
+int a١ = 1; // valid, Arabic digits are considered different
+int a1 = 2;
+int a⁰ = 1; // non-portable, gcc and clang extension
+int a𝟬 = 1; // valid, but not a good idea
+int a0 = 2;
+unsigned Ⅾ; // valid, roman digit 500, really a bad idea