aboutsummaryrefslogtreecommitdiffstats
path: root/libcmap_find_codepoint_data.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-10-16 22:13:02 +0200
committerMattias Andrée <m@maandree.se>2026-10-16 22:13:02 +0200
commit8f2086b5289ee484f9cded05f477096f50d17076 (patch)
treecb3780441708288ae702138eeb82b26412bc296d /libcmap_find_codepoint_data.c
parentFix libcmap_find_block and libcmap_find_script (diff)
downloadlibcmap-8f2086b5289ee484f9cded05f477096f50d17076.tar.gz
libcmap-8f2086b5289ee484f9cded05f477096f50d17076.tar.bz2
libcmap-8f2086b5289ee484f9cded05f477096f50d17076.tar.xz
Add codepoint data and Unicode version
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libcmap_find_codepoint_data.c')
-rw-r--r--libcmap_find_codepoint_data.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/libcmap_find_codepoint_data.c b/libcmap_find_codepoint_data.c
new file mode 100644
index 0000000..cd2e52f
--- /dev/null
+++ b/libcmap_find_codepoint_data.c
@@ -0,0 +1,25 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+
+const struct libcmap_codepoint_data *
+libcmap_find_codepoint_data(uint32_t codepoint)
+{
+ size_t low = 0u, high = libcmap_codepoint_list_size - 1u;
+ size_t i;
+
+ while (low <= high) {
+ i = low + (high - low) / 2u;
+ if (libcmap_codepoint_list[i].range.last < codepoint) {
+ low = i + 1u;
+ } else if (libcmap_codepoint_list[i].range.first > codepoint) {
+ if (!high)
+ break;
+ high = i - 1u;
+ } else {
+ return &libcmap_codepoint_list[i].data[codepoint - libcmap_codepoint_list[i].range.first];
+ }
+ }
+
+ return NULL;
+}