summaryrefslogtreecommitdiffstats
path: root/Modules/cjkcodecs/cjkcommon.h
blob: 19462198e91484e099e914eec50b00fda82b42d4 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
 * cjkcommon.h: Common Constants and Macroes for CJK Character Sets
 *
 * Written by Hye-Shik Chang <perky@FreeBSD.org>
 * $CJKCodecs: cjkcommon.h,v 1.2 2003/12/31 05:46:55 perky Exp $
 */

#ifndef _CJKCOMMON_H_
#define _CJKCOMMON_H_

#ifdef uint32_t
typedef uint32_t ucs4_t;
#else
typedef unsigned int ucs4_t;
#endif

#ifdef uint16_t
typedef uint16_t ucs2_t, DBCHAR;
#else
typedef unsigned short ucs2_t, DBCHAR;
#endif

#define UNIINV  Py_UNICODE_REPLACEMENT_CHARACTER
#define NOCHAR  0xFFFF
#define MULTIC  0xFFFE
#define DBCINV  0xFFFD

struct dbcs_index {
    const ucs2_t   *map;
    unsigned char   bottom, top;
};
typedef struct dbcs_index decode_map;

struct widedbcs_index {
    const ucs4_t   *map;
    unsigned char   bottom, top;
};
typedef struct widedbcs_index widedecode_map;

struct unim_index {
    const DBCHAR   *map;
    unsigned char   bottom, top;
};
typedef struct unim_index encode_map;

struct dbcs_map {
    const char *charset;
    const struct unim_index *encmap;
    const struct dbcs_index *decmap;
};

struct pair_encodemap {
    ucs4_t   uniseq;
    DBCHAR   code;
};

#endif