File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -136,6 +136,19 @@ bool encoding_can_encode_everything(ENCODING_RS_ENCODING const* encoding);
136136/// UB ensues if the argument is `NULL`.
137137bool 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///
Original file line number Diff line number Diff 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.
Original file line number Diff line number Diff line change @@ -3,8 +3,9 @@ name = "rustglue"
33version = " 0.1.0"
44authors = [" 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 ]
1011crate-type = [" staticlib" ]
You can’t perform that action at this time.
0 commit comments