Open Chinese Convert: opencc.h Source File

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

opencc.h
1 /*
2 * Open Chinese Convert
3 *
4 * Copyright 2010-2014 Carbo Kuo <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 "Export.hpp"
25 #include "SimpleConverter.hpp"
26 #include <string>
27
28 extern "C" {
29 #else
30 #include <stddef.h>
31 #endif
32
33 #ifndef OPENCC_EXPORT
34 #define OPENCC_EXPORT
35 #endif
36
48 #define OPENCC_DEFAULT_CONFIG_SIMP_TO_TRAD "s2t.json"
49
55 #define OPENCC_DEFAULT_CONFIG_TRAD_TO_SIMP "t2s.json"
56
62 typedef void* opencc_t;
63
73 OPENCC_EXPORT opencc_t opencc_open(const char* configFileName);
74 #ifdef _MSC_VER
75
84 OPENCC_EXPORT opencc_t opencc_open_w(const wchar_t* configFileName);
85 #endif /* _MSC_VER */
86
94 OPENCC_EXPORT int opencc_close(opencc_t opencc);
95
110 OPENCC_EXPORT size_t opencc_convert_utf8_to_buffer(opencc_t opencc,
111 const char* input,
112 size_t length, char* output);
113
129 OPENCC_EXPORT char* opencc_convert_utf8(opencc_t opencc, const char* input,
130 size_t length);
131
140 OPENCC_EXPORT void opencc_convert_utf8_free(char* str);
141
149 OPENCC_EXPORT const char* opencc_error(void);
150
151 #ifdef __cplusplus
152 } // extern "C"
153 #endif
154
161 #endif
opencc_convert_utf8
OPENCC_EXPORT char * opencc_convert_utf8(opencc_t opencc, const char *input, size_t length)
Converts UTF-8 std::string This function returns an allocated C-Style std::string,...
Definition: SimpleConverter.cpp:152
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 std::string.
Definition: SimpleConverter.cpp:141
opencc_t
void * opencc_t
Type of opencc descriptor.
Definition: opencc.h:62
opencc_open
OPENCC_EXPORT opencc_t opencc_open(const char *configFileName)
Makes an instance of opencc.
Definition: SimpleConverter.cpp:130
opencc_error
OPENCC_EXPORT const char * opencc_error(void)
Returns the last error message.
Definition: SimpleConverter.cpp:168
opencc_convert_utf8_free
OPENCC_EXPORT void opencc_convert_utf8_free(char *str)
Releases allocated buffer by opencc_convert_utf8.
Definition: SimpleConverter.cpp:166
opencc_close
OPENCC_EXPORT int opencc_close(opencc_t opencc)
Destroys an instance of opencc.
Definition: SimpleConverter.cpp:135