harec

[hare] Hare compiler, written in C11 for POSIX OSs
Log | Files | Refs | README | LICENSE

utf8.h (608B)


      1 #ifndef HAREC_UTF8_H
      2 #define HAREC_UTF8_H
      3 
      4 #define UTF8_MAX_SIZE 4
      5 
      6 #define UTF8_INVALID 0x80
      7 
      8 /**
      9  * Grabs the next UTF-8 codepoint and advances the string pointer
     10  */
     11 uint32_t utf8_decode(const char **str);
     12 
     13 /**
     14  * Encodes a codepoint as UTF-8 and returns the length of that codepoint.
     15  */
     16 size_t utf8_encode(char *str, uint32_t ch);
     17 
     18 /**
     19  * Returns the size of the next UTF-8 codepoint
     20  */
     21 int utf8_size(const char *str);
     22 
     23 /**
     24  * Returns the size of a UTF-8 codepoint
     25  */
     26 size_t utf8_cpsize(uint32_t ch);
     27 
     28 /**
     29  * Reads and returns the next codepoint from the file.
     30  */
     31 uint32_t utf8_get(FILE *f);
     32 
     33 #endif