| 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 | |||
| 8 | typedef enum { | ||
| 9 | UTF8, | ||
| 10 | UTF16BE, | ||
| 11 | UTF16LE, | ||
| 12 | UTF32BE, | ||
| 13 | UTF32LE, | ||
| 14 | UNKNOWN_ENCODING, | ||
| 15 | } EncodingType; | ||
| 16 | |||
| 17 | typedef struct { | ||
| 18 | unsigned char bytes[4]; | ||
| 19 | unsigned int len; | ||
| 20 | } ByteOrderMark; | ||
| 21 | |||
| 22 | EncodingType lookup_encoding(const char *name) NONNULL_ARGS; | ||
| 23 | |||
| 24 | 91 | static inline bool encoding_is_utf8(const char *name) | |
| 25 | { | ||
| 26 | 91 | return lookup_encoding(name) == UTF8; | |
| 27 | } | ||
| 28 | |||
| 29 | 8 | static inline bool encoding_type_has_bom(EncodingType type) | |
| 30 | { | ||
| 31 | 8 | return (type >= UTF8 && type <= UTF32LE); | |
| 32 | } | ||
| 33 | |||
| 34 | const char *encoding_normalize(const char *name) NONNULL_ARGS_AND_RETURN; | ||
| 35 | const char *encoding_from_type(EncodingType type) RETURNS_NONNULL; | ||
| 36 | EncodingType detect_encoding_from_bom(const char *buf, size_t size); | ||
| 37 | const ByteOrderMark *get_bom_for_encoding(EncodingType type); | ||
| 38 | |||
| 39 | #endif | ||
| 40 |