dte test coverage


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 50.0% high: ≥ 85.0%
Coverage Exec / Excl / Total
Lines: 100.0% 4 / 0 / 4
Functions: 100.0% 2 / 0 / 2
Branches: -% 0 / 0 / 0

src/encoding.h
Line Branch Exec Source
1 #ifndef ENCODING_H
2 #define ENCODING_H
3
4 #include <stdbool.h>
5 #include <stddef.h>
6 #include "util/macros.h"
7 #include "util/string-view.h"
8
9 typedef enum {
10 UTF8,
11 UTF16BE,
12 UTF16LE,
13 UTF32BE,
14 UTF32LE,
15 UNKNOWN_ENCODING,
16 } EncodingType;
17
18 typedef struct {
19 unsigned char bytes[4];
20 unsigned int len;
21 } ByteOrderMark;
22
23 EncodingType lookup_encoding(const char *name) NONNULL_ARGS;
24
25 92 static inline bool encoding_is_utf8(const char *name)
26 {
27 92 return lookup_encoding(name) == UTF8;
28 }
29
30 8 static inline bool encoding_type_has_bom(EncodingType type)
31 {
32 8 return (type >= UTF8 && type <= UTF32LE);
33 }
34
35 const char *encoding_normalize(const char *name) NONNULL_ARGS_AND_RETURN;
36 const char *encoding_from_type(EncodingType type) RETURNS_NONNULL;
37 EncodingType detect_encoding_from_bom(StringView text);
38 const ByteOrderMark *get_bom_for_encoding(EncodingType type);
39
40 #endif
41