Loading...
Searching...
No Matches
opencc.h
/*
* Open Chinese Convert
*
* Copyright 2010-2026 Carbo Kuo and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __OPENCC_H_
#define __OPENCC_H_
#ifdef __cplusplus
#include "Export.hpp"
#include "SimpleConverter.hpp"
#include <string>
extern "C" {
#else
#include <stddef.h>
#endif
#ifndef OPENCC_EXPORT
#define OPENCC_EXPORT
#endif
#define OPENCC_DEFAULT_CONFIG_SIMP_TO_TRAD "s2t.json"
#define OPENCC_DEFAULT_CONFIG_TRAD_TO_SIMP "t2s.json"
typedef void* opencc_t;
OPENCC_EXPORT opencc_t opencc_open(const char* configFileName);
#ifdef _MSC_VER
OPENCC_EXPORT opencc_t opencc_open_w(const wchar_t* configFileName);
#endif /* _MSC_VER */
OPENCC_EXPORT int opencc_close(opencc_t opencc);
OPENCC_EXPORT size_t opencc_convert_utf8_to_buffer(opencc_t opencc,
const char* input,
size_t length, char* output);
OPENCC_EXPORT char* opencc_convert_utf8(opencc_t opencc, const char* input,
size_t length);
OPENCC_EXPORT void opencc_convert_utf8_free(char* str);
OPENCC_EXPORT const char* opencc_error(void);
#ifdef __cplusplus
} // extern "C"
#endif
#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:198
opencc_open
OPENCC_EXPORT opencc_t opencc_open(const char *configFileName)
Makes an instance of opencc.
Definition SimpleConverter.cpp:176
opencc_error
OPENCC_EXPORT const char * opencc_error(void)
Returns the last error message.
Definition SimpleConverter.cpp:214
opencc_convert_utf8_free
OPENCC_EXPORT void opencc_convert_utf8_free(char *str)
Releases allocated buffer by opencc_convert_utf8.
Definition SimpleConverter.cpp:212
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:187
opencc_t
void * opencc_t
Type of opencc descriptor.
Definition opencc.h:62
opencc_close
OPENCC_EXPORT int opencc_close(opencc_t opencc)
Destroys an instance of opencc.
Definition SimpleConverter.cpp:181