| 1 |
// -*- coding:unix; mode:c++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- |
| 2 |
/*------------------------------------------------------------------------------ |
| 3 |
VnConv: Vietnamese Encoding Converter Library |
| 4 |
UniKey Project: http://unikey.sourceforge.net |
| 5 |
Copyleft (C) 1998-2002 Pham Kim Long |
| 6 |
Contact: [email protected] |
| 7 |
|
| 8 |
This program is free software; you can redistribute it and/or |
| 9 |
modify it under the terms of the GNU General Public License |
| 10 |
as published by the Free Software Foundation; either version 2 |
| 11 |
of the License, or (at your option) any later version. |
| 12 |
|
| 13 |
This program is distributed in the hope that it will be useful, |
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
GNU General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with this program; if not, write to the Free Software |
| 20 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. |
| 21 |
--------------------------------------------------------------------------------*/ |
| 22 |
|
| 23 |
// |
| 24 |
#ifndef __VN_CONVERT_H |
| 25 |
#define __VN_CONVERT_H |
| 26 |
|
| 27 |
#if defined(_WIN32) |
| 28 |
#if defined(UNIKEYHOOK) |
| 29 |
#define DllInterface __declspec( dllexport ) |
| 30 |
#else |
| 31 |
#define DllInterface __declspec( dllimport ) |
| 32 |
#endif |
| 33 |
#define DllExport __declspec( dllexport ) |
| 34 |
#define DllImport __declspec( dllimport ) |
| 35 |
#else |
| 36 |
#define DllInterface //not used |
| 37 |
#define DllExport |
| 38 |
#define DllImport |
| 39 |
#endif |
| 40 |
|
| 41 |
#define CONV_CHARSET_UNICODE 0 |
| 42 |
#define CONV_CHARSET_UNIUTF8 1 |
| 43 |
#define CONV_CHARSET_UNIREF 2 //&#D; |
| 44 |
#define CONV_CHARSET_UNIREF_HEX 3 |
| 45 |
#define CONV_CHARSET_UNIDECOMPOSED 4 |
| 46 |
#define CONV_CHARSET_WINCP1258 5 |
| 47 |
#define CONV_CHARSET_UNI_CSTRING 6 |
| 48 |
#define CONV_CHARSET_VNSTANDARD 7 |
| 49 |
|
| 50 |
#define CONV_CHARSET_VIQR 10 |
| 51 |
#define CONV_CHARSET_UTF8VIQR 11 |
| 52 |
#define CONV_CHARSET_XUTF8 12 |
| 53 |
|
| 54 |
#define CONV_CHARSET_TCVN3 20 |
| 55 |
#define CONV_CHARSET_VPS 21 |
| 56 |
#define CONV_CHARSET_VISCII 22 |
| 57 |
#define CONV_CHARSET_BKHCM1 23 |
| 58 |
#define CONV_CHARSET_VIETWAREF 24 |
| 59 |
#define CONV_CHARSET_ISC 25 |
| 60 |
|
| 61 |
#define CONV_CHARSET_VNIWIN 40 |
| 62 |
#define CONV_CHARSET_BKHCM2 41 |
| 63 |
#define CONV_CHARSET_VIETWAREX 42 |
| 64 |
#define CONV_CHARSET_VNIMAC 43 |
| 65 |
|
| 66 |
#define CONV_TOTAL_SINGLE_CHARSETS 6 |
| 67 |
#define CONV_TOTAL_DOUBLE_CHARSETS 4 |
| 68 |
|
| 69 |
|
| 70 |
#define IS_SINGLE_BYTE_CHARSET(x) (x >= CONV_CHARSET_TCVN3 && x < CONV_CHARSET_TCVN3+CONV_TOTAL_SINGLE_CHARSETS) |
| 71 |
#define IS_DOUBLE_BYTE_CHARSET(x) (x >= CONV_CHARSET_VNIWIN && x < CONV_CHARSET_VNIWIN+CONV_TOTAL_DOUBLE_CHARSETS) |
| 72 |
|
| 73 |
typedef unsigned char UKBYTE; |
| 74 |
|
| 75 |
#if defined(__cplusplus) |
| 76 |
extern "C" { |
| 77 |
#endif |
| 78 |
DllInterface int VnConvert(int inCharset, int outCharset, UKBYTE *input, UKBYTE *output, |
| 79 |
int * pInLen, int * pMaxOutLen); |
| 80 |
|
| 81 |
DllInterface int VnFileConvert(int inCharset, int outCharset, const char *inFile, const char *outFile); |
| 82 |
|
| 83 |
#if defined(__cplusplus) |
| 84 |
} |
| 85 |
#endif |
| 86 |
|
| 87 |
DllInterface const char * VnConvErrMsg(int errCode); |
| 88 |
|
| 89 |
enum VnConvError { |
| 90 |
VNCONV_NO_ERROR, |
| 91 |
VNCONV_UNKNOWN_ERROR, |
| 92 |
VNCONV_INVALID_CHARSET, |
| 93 |
VNCONV_ERR_INPUT_FILE, |
| 94 |
VNCONV_ERR_OUTPUT_FILE, |
| 95 |
VNCONV_OUT_OF_MEMORY, |
| 96 |
VNCONV_ERR_WRITING, |
| 97 |
VNCONV_LAST_ERROR |
| 98 |
}; |
| 99 |
|
| 100 |
typedef struct _CharsetNameId CharsetNameId; |
| 101 |
|
| 102 |
struct _CharsetNameId { |
| 103 |
const char *name; |
| 104 |
int id; |
| 105 |
}; |
| 106 |
|
| 107 |
typedef struct _VnConvOptions VnConvOptions; |
| 108 |
|
| 109 |
struct _VnConvOptions { |
| 110 |
int viqrMixed; |
| 111 |
int viqrEsc; |
| 112 |
int toUpper; |
| 113 |
int toLower; |
| 114 |
int removeTone; |
| 115 |
int smartViqr; |
| 116 |
}; |
| 117 |
|
| 118 |
DllInterface void VnConvSetOptions(VnConvOptions *pOptions); |
| 119 |
DllInterface void VnConvGetOptions(VnConvOptions *pOptions); |
| 120 |
DllInterface void VnConvResetOptions(VnConvOptions *pOptions); |
| 121 |
|
| 122 |
#endif |