summaryrefslogtreecommitdiff
path: root/singlebytecodec.h
blob: 08aef9b36530fb80a08c1bc8f7e7ee27d90237c4 (plain)
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
27
28
29
30
31
32
33
34
35
36
37
#ifndef SINGLEBYTECODEC_H
#define SINGLEBYTECODEC_H

#include "uniconvint.h"

struct encoding_map {
    uc_char_t from;
    int to;
};

typedef struct _SingleByteCodecState {
    const char *encoding;
    const int *decoding_table;
    size_t decoding_table_size;
    const struct encoding_map *encoding_map;
    size_t encoding_map_size;
} SingleByteCodecState;

int
sbcs_init(SingleByteCodecState *state, const char *encoding);

int
sbcs_encode(SingleByteCodecState *state,
	    const uc_char_t **inbuf,
	    size_t inleft,
	    char **outbuf,
	    size_t outbytesleft);


int
sbcs_decode(SingleByteCodecState *state,
	    const char **inbuf,
	    size_t inbytesleft,
	    uc_char_t **outbuf,
	    size_t outleft);

#endif