Open Chinese Convert 1.0.1 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 #endif
29
41 #define OPENCC_DEFAULT_CONFIG_SIMP_TO_TRAD "st2.json"
42
48 #define OPENCC_DEFAULT_CONFIG_TRAD_TO_SIMP "t2s.json"
49
55 typedef void* opencc_t;
56
66 OPENCC_EXPORT opencc_t opencc_open(const char* configFileName);
67
75 OPENCC_EXPORT int opencc_close(opencc_t opencc);
76
91 OPENCC_EXPORT size_t opencc_convert_utf8_to_buffer(opencc_t opencc,
92 const char* input,
93 size_t length,
94 char* output);
95
111 OPENCC_EXPORT char* opencc_convert_utf8(opencc_t opencc,
112 const char* input,
113 size_t length);
114
122 OPENCC_EXPORT void opencc_convert_utf8_free(char* str);
123
131 OPENCC_EXPORT const char* opencc_error(void);
132
133 #ifdef __cplusplus
134 }
135 #endif
136
143 namespace opencc {
149 class OPENCC_EXPORT SimpleConverter {
150 public:
155 SimpleConverter(const std::string& configFileName);
156
157 ~SimpleConverter();
158
163 std::string Convert(const std::string& input) const;
164
169 std::string Convert(const char* input) const;
170
176 std::string Convert(const char* input, size_t length) const;
177
185 size_t Convert(const char* input, char* output) const;
186
195 size_t Convert(const char* input, size_t length, char* output) const;
196
197 private:
198 const void* internalData;
199 };
200 }
201
208 #endif
opencc_close
OPENCC_EXPORT int opencc_close(opencc_t opencc)
Destroys an instance of opencc.
Definition: SimpleConverter.cpp:102
opencc::SimpleConverter
A high level converter This interface does not require C++11 to compile.
Definition: opencc.h:149
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:55
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