Open Chinese Convert  0.4.3
A project for conversion between Traditional and Simplified Chinese
 All Data Structures Files Functions Variables Groups Pages
opencc.h
Go to the documentation of this file.
1 
23 #ifndef __OPENCC_H_
24 #define __OPENCC_H_
25 
32 #include "opencc_types.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
43 #define OPENCC_DEFAULT_CONFIG_SIMP_TO_TRAD "zhs2zht.ini"
44 
50 #define OPENCC_DEFAULT_CONFIG_TRAD_TO_SIMP "zht2zhs.ini"
51 
61 opencc_t opencc_open(const char* config_file);
62 
69 int opencc_close(opencc_t od);
70 
86 size_t opencc_convert(opencc_t od,
87  ucs4_t** inbuf,
88  size_t* inbufleft,
89  ucs4_t** outbuf,
90  size_t* outbufleft);
91 
107 char* opencc_convert_utf8(opencc_t od, const char* inbuf, size_t length);
108 
116 void opencc_convert_utf8_free(char* buf);
117 
130 int opencc_dict_load(opencc_t od,
131  const char* dict_filename,
132  opencc_dictionary_type dict_type);
133 
144 void opencc_set_conversion_mode(opencc_t od,
145  opencc_conversion_mode conversion_mode);
146 
152 opencc_error opencc_errno(void);
153 
160 void opencc_perror(const char* spec);
161 
162 #ifdef __cplusplus
163 }
164 #endif
165 
166 #endif /* __OPENCC_H_ */
char * opencc_convert_utf8(opencc_t od, const char *inbuf, size_t length)
Converts UTF-8 string from inbuf.
Definition: opencc.c:66
opencc_t opencc_open(const char *config_file)
Makes an instance of opencc.
Definition: opencc.c:142
void opencc_convert_utf8_free(char *buf)
Releases allocated buffer by opencc_convert_utf8.
Definition: opencc.c:138
int opencc_close(opencc_t od)
Destroys an instance of opencc.
Definition: opencc.c:168
int opencc_dict_load(opencc_t od, const char *dict_filename, opencc_dictionary_type dict_type)
Loads a dictionary to default dictionary chain.
Definition: opencc.c:181
opencc_error opencc_errno(void)
Returns an opencc_convert_errno_t which describes the last error.
Definition: opencc.c:213
void opencc_perror(const char *spec)
Prints the error message to stderr.
Definition: opencc.c:220
void opencc_set_conversion_mode(opencc_t od, opencc_conversion_mode conversion_mode)
Changes the mode of conversion.
Definition: opencc.c:204
size_t opencc_convert(opencc_t od, ucs4_t **inbuf, size_t *inbufleft, ucs4_t **outbuf, size_t *outbufleft)
Converts a UCS-4 string from *inbuf to *outbuf.
Definition: opencc.c:46