libgrapheme

Freestanding C library for unicode string handling
git clone https://git.sinitax.com/suckless/libgrapheme
Log | Files | Refs | README | LICENSE | sfeed.txt

util.h (1936B)


      1/* See LICENSE file for copyright and license details. */
      2#ifndef UTIL_H
      3#define UTIL_H
      4
      5#include <stddef.h>
      6#include <stdint.h>
      7
      8#include "types.h"
      9
     10#define LEN(x) (sizeof(x) / sizeof *(x))
     11
     12struct property_spec {
     13	const char *enumname;
     14	const char *file;
     15	const char *ucdname;
     16};
     17
     18struct properties {
     19	int_least64_t property;
     20};
     21
     22struct properties_compressed {
     23	size_t *offset;
     24	struct properties *data;
     25	size_t datalen;
     26};
     27
     28struct properties_major_minor {
     29	size_t *major;
     30	size_t *minor;
     31	size_t minorlen;
     32};
     33
     34int hextocp(const char *, size_t, uint_least32_t *cp);
     35int parse_cp_list(const char *, uint_least32_t **, size_t *);
     36
     37void parse_file_with_callback(const char *,
     38                              int (*callback)(const char *, char **, size_t,
     39                                              char *, void *),
     40                              void *payload);
     41
     42void properties_compress(const struct properties *,
     43                         struct properties_compressed *comp);
     44double properties_get_major_minor(const struct properties_compressed *,
     45                                  struct properties_major_minor *);
     46void properties_print_lookup_table(const char *, const size_t *, size_t);
     47void properties_print_derived_lookup_table(
     48	char *, size_t *, size_t,
     49	int_least64_t (*get_value)(const struct properties *, size_t),
     50	const void *);
     51
     52void properties_generate_break_property(
     53	const struct property_spec *, uint_least8_t,
     54	uint_least8_t (*fill_missing)(uint_least32_t),
     55	uint_least8_t (*handle_conflict)(uint_least32_t, uint_least8_t,
     56                                         uint_least8_t),
     57	void (*post_process)(struct properties *), const char *, const char *);
     58
     59void break_test_list_parse(char *, struct break_test **, size_t *);
     60void break_test_list_print(const struct break_test *, size_t, const char *,
     61                           const char *);
     62void break_test_list_free(struct break_test *, size_t);
     63
     64#endif /* UTIL_H */