Open Chinese Convert: opencc.h Source File

Open Chinese Convert 1.0.2 A project for conversion between Traditional and Simplified Chinese

- Main Page
- Modules
- Classes
- Examples

All Classes Functions Typedefs Modules
opencc.h
1 /*
2 * Open Chinese Convert
3 *
4 * Copyright 2010-2014 BYVoid <byvoid@byvoid.com>
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 #ifndef __OPENCC_H_
20 #define __OPENCC_H_
21
22 #ifdef __cplusplus
23
24 #include <string>
25 #include "Export.hpp"
26
27 extern "C" {
28 #else
29 #include <stddef.h>
30 #endif
31
32 #ifndef OPENCC_EXPORT
33 #define OPENCC_EXPORT
34 #endif
35
47 #define OPENCC_DEFAULT_CONFIG_SIMP_TO_TRAD "s2t.json"
48
54 #define OPENCC_DEFAULT_CONFIG_TRAD_TO_SIMP "t2s.json"
55
61 typedef void* opencc_t;
62
72 OPENCC_EXPORT opencc_t opencc_open(const char* configFileName);
73
81 OPENCC_EXPORT int opencc_close(opencc_t opencc);
82
97 OPENCC_EXPORT size_t opencc_convert_utf8_to_buffer(opencc_t opencc,
98 const char* input,
99 size_t length,
100 char* output);
101
117 OPENCC_EXPORT char* opencc_convert_utf8(opencc_t opencc,
118 const char* input,
119 size_t length);
120
128 OPENCC_EXPORT void opencc_convert_utf8_free(char* str);
129
137 OPENCC_EXPORT const char* opencc_error(void);
138
139 #ifdef __cplusplus
140 }
141
148 namespace opencc {
154 class OPENCC_EXPORT SimpleConverter {
155 public:
160 SimpleConverter(const std::string& configFileName);
161
162 ~SimpleConverter();
163
168 std::string Convert(const std::string& input) const;
169
174 std::string Convert(const char* input) const;
175
181 std::string Convert(const char* input, size_t length) const;
182
190 size_t Convert(const char* input, char* output) const;
191
200 size_t Convert(const char* input, size_t length, char* output) const;
201
202 private:
203 const void* internalData;
204 };
205 }
206 #endif
207
214 #endif
opencc_close
OPENCC_EXPORT int opencc_close(opencc_t opencc)
Destroys an instance of opencc.
Definition: SimpleConverter.cpp:102
opencc_convert_utf8_to_buffer
OPENCC_EXPORT size_t opencc_convert_utf8_to_buffer(opencc_t opencc, const char *input, size_t length, char *output)
Converts UTF-8 string.
Definition: SimpleConverter.cpp:113
opencc_convert_utf8
OPENCC_EXPORT char * opencc_convert_utf8(opencc_t opencc, const char *input, size_t length)
Converts UTF-8 string This function returns an allocated C-Style string, which stores the converted s...
Definition: SimpleConverter.cpp:126
opencc_t
void * opencc_t
Type of opencc descriptor.
Definition: opencc.h:61
opencc_open
OPENCC_EXPORT opencc_t opencc_open(const char *configFileName)
Makes an instance of opencc.
Definition: SimpleConverter.cpp:89
opencc
Definition: BinaryDict.hpp:24
opencc_error
OPENCC_EXPORT const char * opencc_error(void)
Returns the last error message.
Definition: SimpleConverter.cpp:144
opencc_convert_utf8_free
OPENCC_EXPORT void opencc_convert_utf8_free(char *str)
Releases allocated buffer by opencc_convert_utf8.
Definition: SimpleConverter.cpp:140