libgrapheme

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

grapheme.h (2782B)


      1/* See LICENSE file for copyright and license details. */
      2#ifndef GRAPHEME_H
      3#define GRAPHEME_H
      4
      5#include <stdbool.h>
      6#include <stddef.h>
      7#include <stdint.h>
      8
      9#define GRAPHEME_INVALID_CODEPOINT UINT32_C(0xFFFD)
     10
     11enum grapheme_bidirectional_direction {
     12	GRAPHEME_BIDIRECTIONAL_DIRECTION_NEUTRAL,
     13	GRAPHEME_BIDIRECTIONAL_DIRECTION_LTR,
     14	GRAPHEME_BIDIRECTIONAL_DIRECTION_RTL,
     15};
     16
     17size_t grapheme_bidirectional_get_line_embedding_levels(const uint_least32_t *,
     18                                                        size_t, int_least8_t *,
     19                                                        size_t);
     20
     21size_t grapheme_bidirectional_preprocess_paragraph(
     22	const uint_least32_t *, size_t, enum grapheme_bidirectional_direction,
     23	uint_least32_t *, size_t, enum grapheme_bidirectional_direction *);
     24
     25size_t grapheme_bidirectional_reorder_line(const uint_least32_t *,
     26                                           const uint_least32_t *, size_t,
     27                                           uint_least32_t *, size_t);
     28
     29size_t grapheme_decode_utf8(const char *, size_t, uint_least32_t *);
     30size_t grapheme_encode_utf8(uint_least32_t, char *, size_t);
     31
     32bool grapheme_is_character_break(uint_least32_t, uint_least32_t,
     33                                 uint_least16_t *);
     34
     35bool grapheme_is_lowercase(const uint_least32_t *, size_t, size_t *);
     36bool grapheme_is_titlecase(const uint_least32_t *, size_t, size_t *);
     37bool grapheme_is_uppercase(const uint_least32_t *, size_t, size_t *);
     38
     39bool grapheme_is_lowercase_utf8(const char *, size_t, size_t *);
     40bool grapheme_is_titlecase_utf8(const char *, size_t, size_t *);
     41bool grapheme_is_uppercase_utf8(const char *, size_t, size_t *);
     42
     43size_t grapheme_next_character_break(const uint_least32_t *, size_t);
     44size_t grapheme_next_line_break(const uint_least32_t *, size_t);
     45size_t grapheme_next_sentence_break(const uint_least32_t *, size_t);
     46size_t grapheme_next_word_break(const uint_least32_t *, size_t);
     47
     48size_t grapheme_next_character_break_utf8(const char *, size_t);
     49size_t grapheme_next_line_break_utf8(const char *, size_t);
     50size_t grapheme_next_sentence_break_utf8(const char *, size_t);
     51size_t grapheme_next_word_break_utf8(const char *, size_t);
     52
     53size_t grapheme_to_lowercase(const uint_least32_t *, size_t, uint_least32_t *,
     54                             size_t);
     55size_t grapheme_to_titlecase(const uint_least32_t *, size_t, uint_least32_t *,
     56                             size_t);
     57size_t grapheme_to_uppercase(const uint_least32_t *, size_t, uint_least32_t *,
     58                             size_t);
     59
     60size_t grapheme_to_lowercase_utf8(const char *, size_t, char *, size_t);
     61size_t grapheme_to_titlecase_utf8(const char *, size_t, char *, size_t);
     62size_t grapheme_to_uppercase_utf8(const char *, size_t, char *, size_t);
     63
     64#endif /* GRAPHEME_H */