libgrapheme

unicode string library
git clone git://git.suckless.org/libgrapheme
Log | Files | Refs | README | LICENSE

grapheme.h (3206B)


      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 
     11 /* TODO call it simply "direction" without override */
     12 enum grapheme_bidirectional_override {
     13 	GRAPHEME_BIDIRECTIONAL_OVERRIDE_NEUTRAL,
     14 	GRAPHEME_BIDIRECTIONAL_OVERRIDE_LTR,
     15 	GRAPHEME_BIDIRECTIONAL_OVERRIDE_RTL,
     16 };
     17 
     18 void grapheme_bidirectional_get_line_embedding_levels(const uint_least32_t *,
     19                                                       size_t, int_least8_t *);
     20 
     21 size_t grapheme_bidirectional_preprocess(const uint_least32_t *, size_t,
     22                                          enum grapheme_bidirectional_override,
     23                                          uint_least32_t *, size_t);
     24 size_t
     25 grapheme_bidirectional_preprocess_utf8(const char *, size_t,
     26                                        enum grapheme_bidirectional_override,
     27                                        uint_least32_t *, size_t);
     28 
     29 size_t grapheme_bidirectional_reorder_line(const uint_least32_t *,
     30                                            const int_least8_t *, size_t,
     31                                            uint_least32_t *, size_t);
     32 size_t grapheme_bidirectional_reorder_line_utf8(const char *,
     33                                                 const int_least8_t *, size_t,
     34                                                 char *, size_t);
     35 
     36 size_t grapheme_decode_utf8(const char *, size_t, uint_least32_t *);
     37 size_t grapheme_encode_utf8(uint_least32_t, char *, size_t);
     38 
     39 bool grapheme_is_character_break(uint_least32_t, uint_least32_t,
     40                                  uint_least16_t *);
     41 
     42 bool grapheme_is_lowercase(const uint_least32_t *, size_t, size_t *);
     43 bool grapheme_is_titlecase(const uint_least32_t *, size_t, size_t *);
     44 bool grapheme_is_uppercase(const uint_least32_t *, size_t, size_t *);
     45 
     46 bool grapheme_is_lowercase_utf8(const char *, size_t, size_t *);
     47 bool grapheme_is_titlecase_utf8(const char *, size_t, size_t *);
     48 bool grapheme_is_uppercase_utf8(const char *, size_t, size_t *);
     49 
     50 size_t grapheme_next_character_break(const uint_least32_t *, size_t);
     51 size_t grapheme_next_line_break(const uint_least32_t *, size_t);
     52 size_t grapheme_next_sentence_break(const uint_least32_t *, size_t);
     53 size_t grapheme_next_word_break(const uint_least32_t *, size_t);
     54 
     55 size_t grapheme_next_character_break_utf8(const char *, size_t);
     56 size_t grapheme_next_line_break_utf8(const char *, size_t);
     57 size_t grapheme_next_sentence_break_utf8(const char *, size_t);
     58 size_t grapheme_next_word_break_utf8(const char *, size_t);
     59 
     60 size_t grapheme_to_lowercase(const uint_least32_t *, size_t, uint_least32_t *,
     61                              size_t);
     62 size_t grapheme_to_titlecase(const uint_least32_t *, size_t, uint_least32_t *,
     63                              size_t);
     64 size_t grapheme_to_uppercase(const uint_least32_t *, size_t, uint_least32_t *,
     65                              size_t);
     66 
     67 size_t grapheme_to_lowercase_utf8(const char *, size_t, char *, size_t);
     68 size_t grapheme_to_titlecase_utf8(const char *, size_t, char *, size_t);
     69 size_t grapheme_to_uppercase_utf8(const char *, size_t, char *, size_t);
     70 
     71 #endif /* GRAPHEME_H */