| 1 |
/* |
| 2 |
* SPDX-FileCopyrightText: 1998-2002 Pham Kim Long <[email protected]> |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 5 |
*/ |
| 6 |
|
| 7 |
#ifndef __VN_CONVERT_H |
| 8 |
#define __VN_CONVERT_H |
| 9 |
|
| 10 |
#if defined(_WIN32) |
| 11 |
#if defined(UNIKEYHOOK) |
| 12 |
#define DllInterface __declspec(dllexport) |
| 13 |
#else |
| 14 |
#define DllInterface __declspec(dllimport) |
| 15 |
#endif |
| 16 |
#define DllExport __declspec(dllexport) |
| 17 |
#define DllImport __declspec(dllimport) |
| 18 |
#else |
| 19 |
#define DllInterface // not used |
| 20 |
#define DllExport |
| 21 |
#define DllImport |
| 22 |
#endif |
| 23 |
|
| 24 |
#define CONV_CHARSET_UNICODE 0 |
| 25 |
#define CONV_CHARSET_UNIUTF8 1 |
| 26 |
#define CONV_CHARSET_UNIREF 2 //&#D; |
| 27 |
#define CONV_CHARSET_UNIREF_HEX 3 |
| 28 |
#define CONV_CHARSET_UNIDECOMPOSED 4 |
| 29 |
#define CONV_CHARSET_WINCP1258 5 |
| 30 |
#define CONV_CHARSET_UNI_CSTRING 6 |
| 31 |
#define CONV_CHARSET_VNSTANDARD 7 |
| 32 |
|
| 33 |
#define CONV_CHARSET_VIQR 10 |
| 34 |
#define CONV_CHARSET_UTF8VIQR 11 |
| 35 |
#define CONV_CHARSET_XUTF8 12 |
| 36 |
|
| 37 |
#define CONV_CHARSET_TCVN3 20 |
| 38 |
#define CONV_CHARSET_VPS 21 |
| 39 |
#define CONV_CHARSET_VISCII 22 |
| 40 |
#define CONV_CHARSET_BKHCM1 23 |
| 41 |
#define CONV_CHARSET_VIETWAREF 24 |
| 42 |
#define CONV_CHARSET_ISC 25 |
| 43 |
|
| 44 |
#define CONV_CHARSET_VNIWIN 40 |
| 45 |
#define CONV_CHARSET_BKHCM2 41 |
| 46 |
#define CONV_CHARSET_VIETWAREX 42 |
| 47 |
#define CONV_CHARSET_VNIMAC 43 |
| 48 |
|
| 49 |
#define CONV_TOTAL_SINGLE_CHARSETS 6 |
| 50 |
#define CONV_TOTAL_DOUBLE_CHARSETS 4 |
| 51 |
|
| 52 |
#define IS_SINGLE_BYTE_CHARSET(x) \ |
| 53 |
(x >= CONV_CHARSET_TCVN3 && \ |
| 54 |
x < CONV_CHARSET_TCVN3 + CONV_TOTAL_SINGLE_CHARSETS) |
| 55 |
#define IS_DOUBLE_BYTE_CHARSET(x) \ |
| 56 |
(x >= CONV_CHARSET_VNIWIN && \ |
| 57 |
x < CONV_CHARSET_VNIWIN + CONV_TOTAL_DOUBLE_CHARSETS) |
| 58 |
|
| 59 |
typedef unsigned char UKBYTE; |
| 60 |
|
| 61 |
#if defined(__cplusplus) |
| 62 |
extern "C" { |
| 63 |
#endif |
| 64 |
DllInterface int VnConvert(int inCharset, int outCharset, UKBYTE *input, |
| 65 |
UKBYTE *output, int *pInLen, int *pMaxOutLen); |
| 66 |
|
| 67 |
DllInterface int VnFileConvert(int inCharset, int outCharset, |
| 68 |
const char *inFile, const char *outFile); |
| 69 |
|
| 70 |
#if defined(__cplusplus) |
| 71 |
} |
| 72 |
#endif |
| 73 |
|
| 74 |
DllInterface const char *VnConvErrMsg(int errCode); |
| 75 |
|
| 76 |
enum VnConvError { |
| 77 |
VNCONV_NO_ERROR, |
| 78 |
VNCONV_UNKNOWN_ERROR, |
| 79 |
VNCONV_INVALID_CHARSET, |
| 80 |
VNCONV_ERR_INPUT_FILE, |
| 81 |
VNCONV_ERR_OUTPUT_FILE, |
| 82 |
VNCONV_OUT_OF_MEMORY, |
| 83 |
VNCONV_ERR_WRITING, |
| 84 |
VNCONV_LAST_ERROR |
| 85 |
}; |
| 86 |
|
| 87 |
typedef struct _CharsetNameId CharsetNameId; |
| 88 |
|
| 89 |
struct _CharsetNameId { |
| 90 |
const char *name; |
| 91 |
int id; |
| 92 |
}; |
| 93 |
|
| 94 |
typedef struct _VnConvOptions VnConvOptions; |
| 95 |
|
| 96 |
struct _VnConvOptions { |
| 97 |
int viqrMixed; |
| 98 |
int viqrEsc; |
| 99 |
int toUpper; |
| 100 |
int toLower; |
| 101 |
int removeTone; |
| 102 |
int smartViqr; |
| 103 |
}; |
| 104 |
|
| 105 |
DllInterface void VnConvSetOptions(VnConvOptions *pOptions); |
| 106 |
DllInterface void VnConvGetOptions(VnConvOptions *pOptions); |
| 107 |
DllInterface void VnConvResetOptions(VnConvOptions *pOptions); |
| 108 |
|
| 109 |
#endif |