aboutsummaryrefslogtreecommitdiffstats
path: root/libcmap_find_codepoint_data.c
diff options
context:
space:
mode:
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;
+}