-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathencoding.h
45 lines (37 loc) · 1.21 KB
/
encoding.h
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
38
39
40
41
42
43
44
45
#ifndef __ENCODING__
#define __ENCODING__
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
#include "cell.h"
/*
* Indicate the maximum encoding name index; range is 0 to ENCODING_NAME_MAX.
* Now ready encodings are RAW, UTF-8, EUC-JP and Shift-JIS.
*/
#define ENCODING_NAME_MAX (3)
/* encoding index */
#define NENCODE_RAW (0)
#define NENCODE_UTF8 (1)
#define NENCODE_EUCJP (2)
#define NENCODE_SJIS (3)
/* encoder/decoder error code */
#define EENCODE_BADENCODING (1)
#define EENCODE_LESSLENGTH (2)
#define EENCODE_BAD2NDBYTE (3)
#define EENCODE_OUTOFRANGEUNICODE (4)
typedef struct _encoder_error_info {
int errorno;
int pos;
wchar_t *message;
} encoder_error_info;
wchar_t* get_encoding_name(int enc_idx);
int get_encoding_index(wchar_t *enc_name);
Cell* decode_raw_to_unicode(Cell *raw, int enc, encoder_error_info *error_info);
Cell* encode_unicode_to_raw(Cell *unicode, int enc, encoder_error_info *error_info);
/* for JIS converter */
extern wchar_t Unicode_to_JISX0208[65536];
extern wchar_t JISX0208_to_Unicode[65536];
extern int jisencoder_setup_done;
void JisEncoder_Setup();
#define JISENCODER_INIT() if (jisencoder_setup_done == 0) {JisEncoder_Setup();}
#endif /* __ENCODING__ */