1 | /* uconv.h,v 1.3 2004/09/14 22:27:36 bird Exp */
|
---|
2 | /** @file
|
---|
3 | * IGCC.
|
---|
4 | */
|
---|
5 | /*
|
---|
6 | * Legalesy-free Unicode API interface for OS/2
|
---|
7 | * Unicode Conversions API
|
---|
8 | *
|
---|
9 | * Written by Andrew Zabolotny <bit@eltech.ru>
|
---|
10 | *
|
---|
11 | * This file is put into public domain. You are free to do
|
---|
12 | * literally anything you wish with it: modify, print, sell,
|
---|
13 | * rent, eat, throw out of window: in all (esp. in later)
|
---|
14 | * cases I am not responsible for any damage it causes.
|
---|
15 | */
|
---|
16 |
|
---|
17 | #ifndef __UCONV_H__
|
---|
18 | #define __UCONV_H__
|
---|
19 |
|
---|
20 | #include <unidef.h>
|
---|
21 | #include <sys/cdefs.h>
|
---|
22 |
|
---|
23 | __BEGIN_DECLS
|
---|
24 |
|
---|
25 | /* Substitution options */
|
---|
26 | #define UCONV_OPTION_SUBSTITUTE_FROM_UNICODE 1
|
---|
27 | #define UCONV_OPTION_SUBSTITUTE_TO_UNICODE 2
|
---|
28 | #define UCONV_OPTION_SUBSTITUTE_BOTH 3
|
---|
29 |
|
---|
30 | /* Conversion options */
|
---|
31 | #define CVTTYPE_PATH 0x00000004 /* Treat string as a path */
|
---|
32 | #define CVTTYPE_CDRA 0x00000002 /* Use CDRA control mapping */
|
---|
33 | #define CVTTYPE_CTRL7F 0x00000001 /* Treat 0x7F as a control */
|
---|
34 |
|
---|
35 | /* Conversion bit masks */
|
---|
36 | #define DSPMASK_DATA 0xffffffff
|
---|
37 | #define DSPMASK_DISPLAY 0x00000000
|
---|
38 | #define DSPMASK_TAB 0x00000200
|
---|
39 | #define DSPMASK_LF 0x00000400
|
---|
40 | #define DSPMASK_CR 0x00002000
|
---|
41 | #define DSPMASK_CRLF 0x00002400
|
---|
42 |
|
---|
43 | #define ENDIAN_SYSTEM 0x0000
|
---|
44 | #define ENDIAN_BIG 0xfeff
|
---|
45 | #define ENDIAN_LITTLE 0xfffe
|
---|
46 |
|
---|
47 | typedef struct _conv_endian_t
|
---|
48 | {
|
---|
49 | unsigned short source;
|
---|
50 | unsigned short target;
|
---|
51 | } conv_endian_t;
|
---|
52 |
|
---|
53 | /* Encoding schemes */
|
---|
54 | enum uconv_esid
|
---|
55 | { /* Process Display VIO GPI */
|
---|
56 | ESID_sbcs_data = 0x2100, /* x x x x */
|
---|
57 | ESID_sbcs_pc = 0x3100, /* x x x x */
|
---|
58 | ESID_sbcs_ebcdic = 0x1100, /* x x x */
|
---|
59 | ESID_sbcs_iso = 0x4100, /* x x x x */
|
---|
60 | ESID_sbcs_windows = 0x4105, /* x x x x */
|
---|
61 | ESID_sbcs_alt = 0xF100, /* x x x */
|
---|
62 | ESID_dbcs_data = 0x2200, /* x x */
|
---|
63 | ESID_dbcs_pc = 0x3200, /* x x x x */
|
---|
64 | ESID_dbcs_ebcdic = 0x1200, /* x */
|
---|
65 | ESID_mbcs_data = 0x2300, /* x x x */
|
---|
66 | ESID_mbcs_pc = 0x3300, /* x x */
|
---|
67 | ESID_mbcs_ebcdic = 0x1301, /* */
|
---|
68 | ESID_ucs_2 = 0x7200, /* */
|
---|
69 | ESID_ugl = 0x72FF, /* */
|
---|
70 | ESID_utf_8 = 0x7807, /* x x x */
|
---|
71 | ESID_upf_8 = 0x78FF /* x x x x */
|
---|
72 | };
|
---|
73 |
|
---|
74 | typedef struct _uconv_attribute_t
|
---|
75 | {
|
---|
76 | unsigned long version; /* R/W Version (must be zero) */
|
---|
77 | char mb_min_len; /* R Minimum char size */
|
---|
78 | char mb_max_len; /* R Maximum char size */
|
---|
79 | char usc_min_len; /* R UCS min size */
|
---|
80 | char usc_max_len; /* R UCS max size */
|
---|
81 | unsigned short esid; /* R Encoding scheme ID */
|
---|
82 | char options; /* R/W Substitution options */
|
---|
83 | char state; /* R/W State for stateful convert */
|
---|
84 | conv_endian_t endian; /* R/W Source and target endian */
|
---|
85 | unsigned long displaymask; /* R/W Display/data mask */
|
---|
86 | unsigned long converttype; /* R/W Conversion type */
|
---|
87 | unsigned short subchar_len; /* R/W MBCS sub len 0=table */
|
---|
88 | unsigned short subuni_len; /* R/W Unicode sub len 0=table */
|
---|
89 | char subchar [16]; /* R/W MBCS sub characters */
|
---|
90 | UniChar subuni [8]; /* R/W Unicode sub characters */
|
---|
91 | } uconv_attribute_t;
|
---|
92 |
|
---|
93 | /* User defined character range */
|
---|
94 | typedef struct _udcrange_t
|
---|
95 | {
|
---|
96 | unsigned short first;
|
---|
97 | unsigned short last;
|
---|
98 | } udcrange_t;
|
---|
99 |
|
---|
100 | typedef int uconv_error_t;
|
---|
101 | typedef void *UconvObject;
|
---|
102 |
|
---|
103 | int APIENTRY UniCreateUconvObject (UniChar *codepage, UconvObject *uobj);
|
---|
104 | int APIENTRY UniQueryUconvObject (UconvObject uobj, uconv_attribute_t * attr,
|
---|
105 | size_t size, char first [256], char other [256], udcrange_t udcrange[32]);
|
---|
106 | int APIENTRY UniSetUconvObject (UconvObject uobj, uconv_attribute_t * attr);
|
---|
107 | int APIENTRY UniUconvToUcs (UconvObject uobj, void **inbuf, size_t *inbytes,
|
---|
108 | UniChar **outbuf, size_t *outchars, size_t *subst);
|
---|
109 | int APIENTRY UniUconvFromUcs (UconvObject uobj, UniChar **inbuf, size_t *inchars,
|
---|
110 | void **outbuf, size_t *outbytes, size_t *subst);
|
---|
111 | int APIENTRY UniFreeUconvObject (UconvObject uobj);
|
---|
112 | int APIENTRY UniMapCpToUcsCp (unsigned long ulCodePage, UniChar *ucsCodePage, size_t n);
|
---|
113 | int APIENTRY UniStrFromUcs(UconvObject, char *, UniChar *, int len);
|
---|
114 | int APIENTRY UniStrToUcs(UconvObject, UniChar *, char *, int);
|
---|
115 |
|
---|
116 | #define IBM_437 (UniChar *)L"IBM-437"
|
---|
117 | #define IBM_819 (UniChar *)L"IBM-819"
|
---|
118 | #define IBM_850 (UniChar *)L"IBM-850"
|
---|
119 | #define UTF_8 (UniChar *)L"IBM-1208"
|
---|
120 | #define UCS_2 (UniChar *)L"IBM-1200"
|
---|
121 | #define ISO8859_1 (UniChar *)L"IBM-819"
|
---|
122 |
|
---|
123 | /* uconv error aliases. */
|
---|
124 | #define UCONV_BADATTR ULS_BADATTR
|
---|
125 | #define UCONV_E2BIG ULS_BUFFERFULL
|
---|
126 | #define UCONV_EBADF ULS_BADOBJECT
|
---|
127 | #define UCONV_EILSEQ ULS_ILLEGALSEQUENCE
|
---|
128 | #define UCONV_EINVAL ULS_INVALID
|
---|
129 | #define UCONV_EMFILE ULS_MAXFILESPERPROC
|
---|
130 | #define UCONV_ENFILE ULS_MAXFILES
|
---|
131 | #define UCONV_ENOMEM ULS_NOMEMORY
|
---|
132 | #define UCONV_EOTHER ULS_OTHER
|
---|
133 | #define UCONV_NOTIMPLEMENTED ULS_NOTIMPLEMENTED
|
---|
134 |
|
---|
135 | __END_DECLS
|
---|
136 |
|
---|
137 | #endif /* __UCONV_H__ */
|
---|