File: utf8.h

package info (click to toggle)
harec 0.26.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,480 kB
  • sloc: ansic: 20,054; asm: 335; makefile: 116; lisp: 80; sh: 45
file content (26 lines) | stat: -rw-r--r-- 501 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef HAREC_UTF8_H
#define HAREC_UTF8_H
#include <stdint.h>
#include <limits.h>
#include <stdio.h>

#define UTF8_MAX_SIZE 4

#define UTF8_INVALID UINT32_MAX

/**
 * Grabs the next UTF-8 codepoint and advances the string pointer
 */
uint32_t utf8_decode(const char **str);

/**
 * Encodes a codepoint as UTF-8 and returns the length of that codepoint.
 */
size_t utf8_encode(char *str, uint32_t ch);

/**
 * Reads and returns the next codepoint from the file.
 */
uint32_t utf8_get(FILE *f);

#endif