File: vnconv.h

package info (click to toggle)
ibus-unikey 0.7.0~beta1-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 672 kB
  • sloc: cpp: 7,042; xml: 63; makefile: 6
file content (122 lines) | stat: -rw-r--r-- 3,580 bytes parent folder | download | duplicates (9)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// -*- coding:unix; mode:c++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
/*------------------------------------------------------------------------------
VnConv: Vietnamese Encoding Converter Library
UniKey Project: http://unikey.sourceforge.net
Copyleft (C) 1998-2002 Pham Kim Long
Contact: longp@cslab.felk.cvut.cz

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
--------------------------------------------------------------------------------*/

//
#ifndef __VN_CONVERT_H
#define __VN_CONVERT_H

#if defined(_WIN32)
    #if defined(UNIKEYHOOK)
        #define DllInterface   __declspec( dllexport )
    #else
        #define DllInterface   __declspec( dllimport )
    #endif
    #define DllExport   __declspec( dllexport )
    #define DllImport   __declspec( dllimport )
#else
    #define DllInterface //not used
    #define DllExport
    #define DllImport
#endif

#define CONV_CHARSET_UNICODE	0
#define CONV_CHARSET_UNIUTF8    1
#define CONV_CHARSET_UNIREF     2  //&#D;
#define CONV_CHARSET_UNIREF_HEX 3
#define CONV_CHARSET_UNIDECOMPOSED 4
#define CONV_CHARSET_WINCP1258	5
#define CONV_CHARSET_UNI_CSTRING 6
#define CONV_CHARSET_VNSTANDARD 7

#define CONV_CHARSET_VIQR		10
#define CONV_CHARSET_UTF8VIQR 11
#define CONV_CHARSET_XUTF8  12

#define CONV_CHARSET_TCVN3		20
#define CONV_CHARSET_VPS		21
#define CONV_CHARSET_VISCII		22
#define CONV_CHARSET_BKHCM1		23
#define CONV_CHARSET_VIETWAREF	24
#define CONV_CHARSET_ISC        25

#define CONV_CHARSET_VNIWIN		40
#define CONV_CHARSET_BKHCM2		41
#define CONV_CHARSET_VIETWAREX	42
#define CONV_CHARSET_VNIMAC		43

#define CONV_TOTAL_SINGLE_CHARSETS 6
#define CONV_TOTAL_DOUBLE_CHARSETS 4


#define IS_SINGLE_BYTE_CHARSET(x) (x >= CONV_CHARSET_TCVN3 && x < CONV_CHARSET_TCVN3+CONV_TOTAL_SINGLE_CHARSETS)
#define IS_DOUBLE_BYTE_CHARSET(x) (x >= CONV_CHARSET_VNIWIN && x < CONV_CHARSET_VNIWIN+CONV_TOTAL_DOUBLE_CHARSETS)

typedef unsigned char UKBYTE;

#if defined(__cplusplus)
extern "C" {
#endif
DllInterface  int VnConvert(int inCharset, int outCharset, UKBYTE *input, UKBYTE *output, 
		int * pInLen, int * pMaxOutLen);

DllInterface  int VnFileConvert(int inCharset, int outCharset, const char *inFile, const char *outFile);

#if defined(__cplusplus)
}
#endif

DllInterface const char * VnConvErrMsg(int errCode);

enum VnConvError {
	VNCONV_NO_ERROR,
	VNCONV_UNKNOWN_ERROR,
	VNCONV_INVALID_CHARSET,
	VNCONV_ERR_INPUT_FILE,
	VNCONV_ERR_OUTPUT_FILE,
	VNCONV_OUT_OF_MEMORY,
	VNCONV_ERR_WRITING,
	VNCONV_LAST_ERROR
};

typedef struct _CharsetNameId CharsetNameId;

struct _CharsetNameId {
	const char *name;
	int id;
};

typedef struct _VnConvOptions VnConvOptions;

struct _VnConvOptions {
	int viqrMixed;
	int viqrEsc;
	int toUpper;
	int toLower;
	int removeTone;
    int smartViqr;
};

DllInterface void VnConvSetOptions(VnConvOptions *pOptions);
DllInterface void VnConvGetOptions(VnConvOptions *pOptions);
DllInterface void VnConvResetOptions(VnConvOptions *pOptions);

#endif