Skip to content

Commit 2b044dd

Browse files
committed
Update to encoding_c 0.9.1.
1 parent ee4211b commit 2b044dd

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

encoding_rs.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,19 @@ bool encoding_can_encode_everything(ENCODING_RS_ENCODING const* encoding);
136136
/// UB ensues if the argument is `NULL`.
137137
bool encoding_is_ascii_compatible(ENCODING_RS_ENCODING const* encoding);
138138

139+
/// Checks whether this encoding maps one byte to one Basic Multilingual
140+
/// Plane code point (i.e. byte length equals decoded UTF-16 length) and
141+
/// vice versa (for mappable characters).
142+
///
143+
/// `true` iff this encoding is on the list of [Legacy single-byte
144+
/// encodings](https://encoding.spec.whatwg.org/#legacy-single-byte-encodings)
145+
/// in the spec or x-user-defined.
146+
///
147+
/// # Undefined behavior
148+
///
149+
/// UB ensues if the argument is `NULL`.
150+
bool encoding_is_single_byte(ENCODING_RS_ENCODING const* encoding);
151+
139152
/// Returns the _output encoding_ of this encoding. This is UTF-8 for
140153
/// UTF-16BE, UTF-16LE and replacement and the encoding itself otherwise.
141154
///

encoding_rs_cpp.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,20 @@ class Encoding final
804804
return encoding_is_ascii_compatible(this);
805805
}
806806

807+
/**
808+
* Checks whether this encoding maps one byte to one Basic Multilingual
809+
* Plane code point (i.e. byte length equals decoded UTF-16 length) and
810+
* vice versa (for mappable characters).
811+
*
812+
* `true` iff this encoding is on the list of Legacy single-byte
813+
* encodings (https://encoding.spec.whatwg.org/#legacy-single-byte-encodings)
814+
* in the spec or x-user-defined.
815+
*/
816+
inline bool is_single_byte() const
817+
{
818+
return encoding_is_single_byte(this);
819+
}
820+
807821
/**
808822
* Returns the _output encoding_ of this encoding. This is UTF-8 for
809823
* UTF-16BE, UTF-16LE and replacement and the encoding itself otherwise.

rustglue/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ name = "rustglue"
33
version = "0.1.0"
44
authors = ["Henri Sivonen <hsivonen@hsivonen.fi>"]
55

6-
[dependencies]
7-
encoding_c = "0.8.0"
6+
[dependencies.encoding_c]
7+
version = "0.9.1"
8+
features = ["fast-legacy-encode"]
89

910
[lib]
1011
crate-type = ["staticlib"]

0 commit comments

Comments
 (0)