| 1 |
# encoding_c |
| 2 |
|
| 3 |
[](https://crates.io/crates/encoding_c) |
| 4 |
[](https://docs.rs/encoding_c/) |
| 5 |
[](https://github.com/hsivonen/encoding_c/blob/master/COPYRIGHT) |
| 6 |
|
| 7 |
encoding_c is an FFI wrapper for [encoding_rs](https://github.com/hsivonen/encoding_rs). |
| 8 |
|
| 9 |
## Bindings for `encoding_rs::mem` |
| 10 |
|
| 11 |
See the [`encoding_c_mem` crate](https://crates.io/crates/encoding_c_mem) |
| 12 |
for bindings for `encoding_rs::mem`. |
| 13 |
|
| 14 |
## Licensing |
| 15 |
|
| 16 |
Please see the file named |
| 17 |
[COPYRIGHT](https://github.com/hsivonen/encoding_c/blob/master/COPYRIGHT). |
| 18 |
|
| 19 |
## No Unwinding Support! |
| 20 |
|
| 21 |
This crate is meant for use in binaries compiled with `panic = 'abort'`, which |
| 22 |
is _required_ for correctness! Unwinding across FFI is Undefined Behavior, and |
| 23 |
this crate does nothing to try to prevent unwinding across the FFI if |
| 24 |
compiled with unwinding enabled. |
| 25 |
|
| 26 |
## C/C++ Headers |
| 27 |
|
| 28 |
`include/encoding_rs.h` and `include/encoding_rs_statics.h` are needed for C |
| 29 |
usage. |
| 30 |
|
| 31 |
`include/encoding_rs_cpp.h` is a sample C++ API built on top of the C API using |
| 32 |
GSL and the C++ standard library. Since C++ project typically roll their own |
| 33 |
string classes, etc., it's probably necessary for C++ projects to manually |
| 34 |
adapt the header to their replacements of standard-library types. |
| 35 |
|
| 36 |
There's a [write-up](https://hsivonen.fi/modern-cpp-in-rust/) about the C++ |
| 37 |
wrappers. |
| 38 |
|
| 39 |
## Release Notes |
| 40 |
|
| 41 |
### 0.9.8 |
| 42 |
|
| 43 |
* Remove year from copyright notices. |
| 44 |
|
| 45 |
### 0.9.7 |
| 46 |
|
| 47 |
* Specify a `links` value in the Cargo manifest. |
| 48 |
* Emit an `include_dir` variable from build script so that other build scripts |
| 49 |
depending on this crate can rely on it. |
| 50 |
|
| 51 |
### 0.9.6 |
| 52 |
|
| 53 |
* Fix a bug in the C++ header. |
| 54 |
|
| 55 |
### 0.9.5 |
| 56 |
|
| 57 |
* Adjust documentation for encoding_rs 0.8.20. |
| 58 |
|
| 59 |
### 0.9.4 |
| 60 |
|
| 61 |
* Fix bogus C header. |
| 62 |
|
| 63 |
### 0.9.3 |
| 64 |
|
| 65 |
* Fix bogus C++ header. |
| 66 |
|
| 67 |
### 0.9.2 |
| 68 |
|
| 69 |
* Wrap `Decoder::latin1_byte_compatible_up_to`. |
| 70 |
|
| 71 |
### 0.9.1 |
| 72 |
|
| 73 |
* Wrap `Encoding::is_single_byte()`. |
| 74 |
* Pass through new feature flags introduced in encoding_rs 0.8.11. |
| 75 |
|
| 76 |
### 0.9.0 |
| 77 |
|
| 78 |
* Update to encoding_rs 0.8.0. |
| 79 |
|
| 80 |
### 0.8.0 |
| 81 |
|
| 82 |
* Update to encoding_rs 0.7.0. |
| 83 |
* Drop `encoding_for_name()`. |
| 84 |
* Deal correctly with the `data()` method of `gsl::span` returning `nullptr`. |
| 85 |
|
| 86 |
### 0.7.6 |
| 87 |
|
| 88 |
* Rename `ENCODING_RS_NON_NULL_CONST_ENCODING_PTR` to |
| 89 |
`ENCODING_RS_NOT_NULL_CONST_ENCODING_PTR`. (Not a breaking change, |
| 90 |
because defining that macro broke the build previously, so the |
| 91 |
macro couldn't have been used.) |
| 92 |
* Use the macro only for statics and not for return values. |
| 93 |
|
| 94 |
### 0.7.5 |
| 95 |
|
| 96 |
* Annotate the encoding pointers that should be wrapped with a |
| 97 |
same-representation not-null type in C++ as |
| 98 |
`ENCODING_RS_NON_NULL_CONST_ENCODING_PTR`. |
| 99 |
|
| 100 |
### 0.7.4 |
| 101 |
|
| 102 |
* Wrap `has_pending_state()`. |
| 103 |
|
| 104 |
### 0.7.3 |
| 105 |
|
| 106 |
* Use C preprocessor definitions for encoding constant declarations. |
| 107 |
|
| 108 |
### 0.7.2 |
| 109 |
|
| 110 |
* Parametrize the struct type names behind C preprocessor definitions. |
| 111 |
* Leave it to the user to provide `char16_t`. Avoid including a header for it. |
| 112 |
|
| 113 |
### 0.7.1 |
| 114 |
|
| 115 |
* Fix documentation for pointers that get used in |
| 116 |
`std::slice::from_raw_parts()`. |
| 117 |
|
| 118 |
### 0.7.0 |
| 119 |
|
| 120 |
* Map `None` to `SIZE_MAX` in the max length calculation functions. |
| 121 |
|
| 122 |
### 0.6.0 |
| 123 |
|
| 124 |
* Check in the `cheddar`-generated header and comment out the `cheddar`-using |
| 125 |
`build.rs`. |
| 126 |
|
| 127 |
### 0.5.0 |
| 128 |
|
| 129 |
* Initial release of encoding_c. (I.e. first release with FFI in a distinct |
| 130 |
crate.) |
| 131 |
|