API in C language.
More...
API in C language.
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.
Do not forget to assign **outbuf to L'\0' after called if you want to use it as a C-Style string.
- Parameters
-
od | The opencc description pointer. |
inbuf | The pointer to the UCS-4 string. |
inbufleft | The maximum number of characters in *inbuf to be converted. |
outbuf | The pointer to the output buffer. |
outbufleft | The size of output buffer. |
- Returns
- The number of characters in the input buffer that has been converted.
Definition at line 46 of file opencc.c.
char* opencc_convert_utf8 |
( |
opencc_t |
od, |
|
|
const char * |
inbuf, |
|
|
size_t |
length |
|
) |
| |
Converts UTF-8 string from inbuf.
This function returns an allocated C-Style string via malloc(), which stores the converted string. You should call opencc_convert_utf8_free() to release allocated memory.
- Parameters
-
od | The opencc description pointer. |
inbuf | The UTF-8 encoded string. |
length | The maximum length of inbuf to convert. If length is set to -1, the whole c-style string in inbuf will be converted. |
- Returns
- The newly allocated UTF-8 string that stores text converted from inbuf.
Definition at line 66 of file opencc.c.
void opencc_convert_utf8_free |
( |
char * |
buf | ) |
|
Releases allocated buffer by opencc_convert_utf8.
- Parameters
-
buf | Pointer to the allocated string buffer by opencc_convert_utf8. |
Definition at line 138 of file opencc.c.
int opencc_dict_load |
( |
opencc_t |
od, |
|
|
const char * |
dict_filename, |
|
|
opencc_dictionary_type |
dict_type |
|
) |
| |
Loads a dictionary to default dictionary chain.
- Parameters
-
od | The opencc description pointer. |
dict_filename | The name (or location) of the dictionary file. |
dict_type | The type of the dictionary. |
- Returns
- 0 on success or non-zero number on failure.
- Deprecated:
- This function is not recommended to use and will be removed.
Definition at line 181 of file opencc.c.
opencc_t opencc_open |
( |
const char * |
config_file | ) |
|
Makes an instance of opencc.
Leave config_file to NULL if you do not want to load any configuration file.
- Parameters
-
config_file | Location of configuration file. |
- Returns
- A description pointer of the newly allocated instance of opencc. On error the return value will be (opencc_t) -1.
Definition at line 142 of file opencc.c.
void opencc_perror |
( |
const char * |
spec | ) |
|
Prints the error message to stderr.
- Parameters
-
Definition at line 220 of file opencc.c.
void opencc_set_conversion_mode |
( |
opencc_t |
od, |
|
|
opencc_conversion_mode |
conversion_mode |
|
) |
| |
Changes the mode of conversion.
- Parameters
-
od | The opencc description pointer. |
conversion_mode | Conversion mode. Options are
- OPENCC_CONVERSION_FAST
- OPENCC_CONVERSION_SEGMENT_ONLY
- OPENCC_CONVERSION_LIST_CANDIDATES
|
Definition at line 204 of file opencc.c.