Skip to content
C bindings for encoding_rs
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
include Wrap `Encoding::is_single_byte()`. Nov 16, 2018
.gitignore Ignore Eclipse settings. Jan 8, 2016
LICENSE-APACHE Add Rust-style Apache/MIT dual license. Jan 4, 2016
LICENSE-MIT Make the FFI code work as a distinct crate. Jan 9, 2017 Link to from the README. Dec 18, 2018 Rename not-null type macro and avoid using it for return values. Jun 21, 2017

encoding_c Apache 2 / MIT dual-licensed

encoding_c is an FFI wrapper for encoding_rs.


Please see the file named COPYRIGHT.

No Unwinding Support!

This crate is meant for use in binaries compiled with panic = 'abort', which is required for correctness! Unwinding across FFI is Undefined Behavior, and this crate does nothing to try to prevent unwinding across the FFI if compliled with unwinding enabled.

C/C++ Headers

include/encoding_rs.h and include/encoding_rs_statics.h are needed for C usage.

include/encoding_rs_cpp.h is a sample C++ API built on top of the C API using GSL and the C++ standard library. Since C++ project typically roll their own string classes, etc., it's probably necessary for C++ projects to manually adapt the header to their replacements of standard-library types.

There's a write-up about the C++ wrappers.

Release Notes


  • Wrap Encoding::is_single_byte().
  • Pass through new feature flags introduced in encoding_rs 0.8.11.


  • Update to encoding_rs 0.8.0.


  • Update to encoding_rs 0.7.0.
  • Drop encoding_for_name().
  • Deal correctly with the data() method of gsl::span returning nullptr.


  • Rename ENCODING_RS_NON_NULL_CONST_ENCODING_PTR to ENCODING_RS_NOT_NULL_CONST_ENCODING_PTR. (Not a breaking change, because defining that macro broke the build previously, so the macro couldn't have been used.)
  • Use the macro only for statics and not for return values.


  • Annotate the encoding pointers that should be wrapped with a same-representation not-null type in C++ as ENCODING_RS_NON_NULL_CONST_ENCODING_PTR.


  • Wrap has_pending_state().


  • Use C preprocessor definitions for encoding constant declarations.


  • Parametrize the struct type names behind C preprocessor definitions.
  • Leave it to the user to provide char16_t. Avoid including a header for it.


  • Fix documentation for pointers that get used in std::slice::from_raw_parts().


  • Map None to SIZE_MAX in the max length calculation functions.


  • Check in the cheddar-generated header and comment out the cheddar-using


  • Initial release of encoding_c. (I.e. first release with FFI in a distinct crate.)
You can’t perform that action at this time.