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