aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/unicode/prop/uprop_get_uc.c134
1 files changed, 134 insertions, 0 deletions
diff --git a/lib/unicode/prop/uprop_get_uc.c b/lib/unicode/prop/uprop_get_uc.c
new file mode 100644
index 0000000..724e034
--- /dev/null
+++ b/lib/unicode/prop/uprop_get_uc.c
@@ -0,0 +1,134 @@
+#include "__bsearch.h"
+#include "macros.h"
+#include "rune.h"
+#include "unicode/prop.h"
+
+#define M(...) ((struct rview)_(__VA_ARGS__))
+#define _(...) \
+ {(const rune []){__VA_ARGS__}, lengthof(((const rune []){__VA_ARGS__}))}
+
+static const struct {
+ rune k;
+ struct rview v;
+} lookup[] = {
+ {0x0149, _(0x02BC, 0x004E)},
+ {0x01F0, _(0x004A, 0x030C)},
+ {0x0390, _(0x0399, 0x0308, 0x0301)},
+ {0x03B0, _(0x03A5, 0x0308, 0x0301)},
+ {0x0587, _(0x0535, 0x0552)},
+ {0x1E96, _(0x0048, 0x0331)},
+ {0x1E97, _(0x0054, 0x0308)},
+ {0x1E98, _(0x0057, 0x030A)},
+ {0x1E99, _(0x0059, 0x030A)},
+ {0x1E9A, _(0x0041, 0x02BE)},
+ {0x1F50, _(0x03A5, 0x0313)},
+ {0x1F52, _(0x03A5, 0x0313, 0x0300)},
+ {0x1F54, _(0x03A5, 0x0313, 0x0301)},
+ {0x1F56, _(0x03A5, 0x0313, 0x0342)},
+ {0x1F80, _(0x1F08, 0x0399)},
+ {0x1F81, _(0x1F09, 0x0399)},
+ {0x1F82, _(0x1F0A, 0x0399)},
+ {0x1F83, _(0x1F0B, 0x0399)},
+ {0x1F84, _(0x1F0C, 0x0399)},
+ {0x1F85, _(0x1F0D, 0x0399)},
+ {0x1F86, _(0x1F0E, 0x0399)},
+ {0x1F87, _(0x1F0F, 0x0399)},
+ {0x1F88, _(0x1F08, 0x0399)},
+ {0x1F89, _(0x1F09, 0x0399)},
+ {0x1F8A, _(0x1F0A, 0x0399)},
+ {0x1F8B, _(0x1F0B, 0x0399)},
+ {0x1F8C, _(0x1F0C, 0x0399)},
+ {0x1F8D, _(0x1F0D, 0x0399)},
+ {0x1F8E, _(0x1F0E, 0x0399)},
+ {0x1F8F, _(0x1F0F, 0x0399)},
+ {0x1F90, _(0x1F28, 0x0399)},
+ {0x1F91, _(0x1F29, 0x0399)},
+ {0x1F92, _(0x1F2A, 0x0399)},
+ {0x1F93, _(0x1F2B, 0x0399)},
+ {0x1F94, _(0x1F2C, 0x0399)},
+ {0x1F95, _(0x1F2D, 0x0399)},
+ {0x1F96, _(0x1F2E, 0x0399)},
+ {0x1F97, _(0x1F2F, 0x0399)},
+ {0x1F98, _(0x1F28, 0x0399)},
+ {0x1F99, _(0x1F29, 0x0399)},
+ {0x1F9A, _(0x1F2A, 0x0399)},
+ {0x1F9B, _(0x1F2B, 0x0399)},
+ {0x1F9C, _(0x1F2C, 0x0399)},
+ {0x1F9D, _(0x1F2D, 0x0399)},
+ {0x1F9E, _(0x1F2E, 0x0399)},
+ {0x1F9F, _(0x1F2F, 0x0399)},
+ {0x1FA0, _(0x1F68, 0x0399)},
+ {0x1FA1, _(0x1F69, 0x0399)},
+ {0x1FA2, _(0x1F6A, 0x0399)},
+ {0x1FA3, _(0x1F6B, 0x0399)},
+ {0x1FA4, _(0x1F6C, 0x0399)},
+ {0x1FA5, _(0x1F6D, 0x0399)},
+ {0x1FA6, _(0x1F6E, 0x0399)},
+ {0x1FA7, _(0x1F6F, 0x0399)},
+ {0x1FA8, _(0x1F68, 0x0399)},
+ {0x1FA9, _(0x1F69, 0x0399)},
+ {0x1FAA, _(0x1F6A, 0x0399)},
+ {0x1FAB, _(0x1F6B, 0x0399)},
+ {0x1FAC, _(0x1F6C, 0x0399)},
+ {0x1FAD, _(0x1F6D, 0x0399)},
+ {0x1FAE, _(0x1F6E, 0x0399)},
+ {0x1FAF, _(0x1F6F, 0x0399)},
+ {0x1FB2, _(0x1FBA, 0x0399)},
+ {0x1FB3, _(0x0391, 0x0399)},
+ {0x1FB4, _(0x0386, 0x0399)},
+ {0x1FB6, _(0x0391, 0x0342)},
+ {0x1FB7, _(0x0391, 0x0342, 0x0399)},
+ {0x1FBC, _(0x0391, 0x0399)},
+ {0x1FC2, _(0x1FCA, 0x0399)},
+ {0x1FC3, _(0x0397, 0x0399)},
+ {0x1FC4, _(0x0389, 0x0399)},
+ {0x1FC6, _(0x0397, 0x0342)},
+ {0x1FC7, _(0x0397, 0x0342, 0x0399)},
+ {0x1FCC, _(0x0397, 0x0399)},
+ {0x1FD2, _(0x0399, 0x0308, 0x0300)},
+ {0x1FD3, _(0x0399, 0x0308, 0x0301)},
+ {0x1FD6, _(0x0399, 0x0342)},
+ {0x1FD7, _(0x0399, 0x0308, 0x0342)},
+ {0x1FE2, _(0x03A5, 0x0308, 0x0300)},
+ {0x1FE3, _(0x03A5, 0x0308, 0x0301)},
+ {0x1FE4, _(0x03A1, 0x0313)},
+ {0x1FE6, _(0x03A5, 0x0342)},
+ {0x1FE7, _(0x03A5, 0x0308, 0x0342)},
+ {0x1FF2, _(0x1FFA, 0x0399)},
+ {0x1FF3, _(0x03A9, 0x0399)},
+ {0x1FF4, _(0x038F, 0x0399)},
+ {0x1FF6, _(0x03A9, 0x0342)},
+ {0x1FF7, _(0x03A9, 0x0342, 0x0399)},
+ {0x1FFC, _(0x03A9, 0x0399)},
+ {0xFB00, _(0x0046, 0x0046)},
+ {0xFB01, _(0x0046, 0x0049)},
+ {0xFB02, _(0x0046, 0x004C)},
+ {0xFB03, _(0x0046, 0x0046, 0x0049)},
+ {0xFB04, _(0x0046, 0x0046, 0x004C)},
+ {0xFB05, _(0x0053, 0x0054)},
+ {0xFB06, _(0x0053, 0x0054)},
+ {0xFB13, _(0x0544, 0x0546)},
+ {0xFB14, _(0x0544, 0x0535)},
+ {0xFB15, _(0x0544, 0x053B)},
+ {0xFB16, _(0x054E, 0x0546)},
+ {0xFB17, _(0x0544, 0x053D)},
+};
+
+__MLIB_DEFINE_BSEARCH_KV(struct rview, lookup, M(ch))
+
+struct rview
+uprop_get_uc(rune ch, struct ucctx ctx)
+{
+ if (ch == U'ß')
+ return ctx.cap_eszett ? M(U'ẞ') : M('S', 'S');
+ if (ch == 'i' && ctx.az_or_tr)
+ return M(U'İ');
+ if (ch == 0x307 && ctx.lt_after_i)
+ return M();
+
+ rune CH = uprop_get_suc(ch);
+ if (ch != CH)
+ return M(CH);
+
+ return mlib_lookup_kv(ch);
+}