From 8f2086b5289ee484f9cded05f477096f50d17076 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 16 Oct 2026 22:13:02 +0200 Subject: Add codepoint data and Unicode version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libcmap_find_codepoint_data.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 libcmap_find_codepoint_data.c (limited to 'libcmap_find_codepoint_data.c') 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; +} -- cgit v1.3.1