Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
OpenCC Rust
Open Chinese Convert(OpenCC, 開放中文轉換) binding for the Rust language for conversion between Traditional Chinese and Simplified Chinese.
Compilation
To compile this crate, you need to compile the OpenCC C++ library first. You can install OpenCC in your operating system, or in somewhere in your file system. As for the latter, you need to set the following environment variables to link the OpenCC library:
OPENCC_LIB_DIRS
: The directories of library files, like-L
. Use:
to separate.OPENCC_LIBS
: The library names that you want to link, like-l
. Use:
to separate. Typically, it contains opencc:marisa.OPENCC_INCLUDE_DIRS
: The directories of header files, like-i
. Use:
to separate.OPENCC_STATIC
: Whether to usestatic
ordylib
.OPENCC_DYLIB_STDCPP
: If you usestatic
linking, and your OpenCC library is compiled by the GNU C, this environment variable should be set.OPENCC_STATIC_STDCPP
: If you usestatic
linking, and your OpenCC library is compiled by musl libc, this environment variable should be set.
Examples
use *;
let opencc = new.unwrap;
let s = opencc.convert;
assert_eq!;
let s = opencc.convert_to_buffer;
assert_eq!;
use *;
let opencc = new.unwrap;
let s = opencc.convert;
assert_eq!;
let s = opencc.convert_to_buffer;
assert_eq!;
Static Dictionaries
Usually, OpenCC needs to be executed on an environment where OpenCC is installed. If you want to make it portable, you can enable the static-dictionaries
feature.
[]
= "*"
= ["static-dictionaries"]
Then, the generate_static_dictionary
and generate_static_dictionaries
functions are available.
The default OpenCC dictionaries will be compiled into the binary file by lazy_static_include
crate. And you can use the two functions to recover them on demand.
For example,
use *;
let output_path = "/path/to/dictionaries-directory";
generate_static_dictionary.unwrap;
let opencc = new.unwrap;
assert_eq!;
Supported Platforms
This crate currently supports Linux. Other platforms are not guaranteed.
Crates.io
https://crates.io/crates/opencc-rust