MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1#ifndef TEXTCODEC_H
2#define TEXTCODEC_H
3
4#include <stdint.h>
5#include <stddef.h>
6#include <stdbool.h>
7
8#include "types.h"
9
10typedef enum {
11 TD_ENC_UTF8 = 0,
12 TD_ENC_UTF16LE,
13 TD_ENC_UTF16BE,
14 TD_ENC_WINDOWS_1252,
15 TD_ENC_ISO_8859_2,
16} td_encoding_t;
17
18typedef struct {
19 td_encoding_t encoding;
20 uint8_t pending[4];
21 int pending_len;
22 bool fatal;
23 bool ignore_bom;
24 bool bom_seen;
25} td_state_t;
26
27void init_textcodec_module(void);
28td_state_t *td_state_new(td_encoding_t enc, bool fatal, bool ignore_bom);
29
30ant_value_t td_decode(ant_t *js, td_state_t *st, const uint8_t *input, size_t input_len, bool stream);
31ant_value_t te_encode(ant_t *js, const char *str, size_t str_len);
32
33
34#endif