Skip to main content

Encoding

Enum Encoding 

Source
#[repr(u32)]
pub enum Encoding {
Show 21 variants Unknown = 0, UsAscii = 1, Iso8859_1 = 2, Iso8859_2 = 3, Iso8859_3 = 4, Iso8859_4 = 5, Iso8859_5 = 6, Iso8859_6 = 7, Iso8859_7 = 8, Iso8859_8 = 9, Iso8859_9 = 10, Iso8859_10 = 11, Iso8859_11 = 12, Iso8859_13 = 13, Iso8859_14 = 14, Iso8859_15 = 15, Iso8859_16 = 16, Koi8R = 17, Iscii = 18, Utf8 = 19, Ucs2 = 20,
}
Expand description

Text encoding, mirroring espeak_ng_ENCODING from encoding.h.

Variants are in the same order as the C enum so that casting a raw integer (e.g. from a binary data file) to Encoding works correctly.

Use Encoding::from_name to resolve an IANA/MIME name, and TextDecoder to decode byte streams.

Variants§

§

Unknown = 0

Encoding not recognised.

§

UsAscii = 1

7-bit US-ASCII.

§

Iso8859_1 = 2

ISO-8859-1 (Latin-1 — Western European).

§

Iso8859_2 = 3

ISO-8859-2 (Latin-2 — Central European).

§

Iso8859_3 = 4

ISO-8859-3 (Latin-3 — South European).

§

Iso8859_4 = 5

ISO-8859-4 (Latin-4 — North European).

§

Iso8859_5 = 6

ISO-8859-5 (Cyrillic).

§

Iso8859_6 = 7

ISO-8859-6 (Arabic).

§

Iso8859_7 = 8

ISO-8859-7 (Greek).

§

Iso8859_8 = 9

ISO-8859-8 (Hebrew).

§

Iso8859_9 = 10

ISO-8859-9 (Latin-5 — Turkish).

§

Iso8859_10 = 11

ISO-8859-10 (Latin-6 — Nordic).

§

Iso8859_11 = 12

ISO-8859-11 (Thai).

§

Iso8859_13 = 13

ISO-8859-13 (Latin-7 — Baltic Rim). Note: 12 is not a valid ISO-8859 number.

§

Iso8859_14 = 14

ISO-8859-14 (Latin-8 — Celtic).

§

Iso8859_15 = 15

ISO-8859-15 (Latin-9 — Western European with €).

§

Iso8859_16 = 16

ISO-8859-16 (Latin-10 — South-Eastern European).

§

Koi8R = 17

KOI8-R (Russian Cyrillic).

§

Iscii = 18

ISCII (Indian scripts).

§

Utf8 = 19

UTF-8 Unicode.

§

Ucs2 = 20

UCS-2 little-endian (16-bit Unicode, no surrogates).

Implementations§

Source§

impl Encoding

Source

pub fn from_name(name: &str) -> Self

Resolve an encoding from its IANA/MIME name.

Mirrors espeak_ng_EncodingFromName() in encoding.c, which uses the mnem_encoding[] table. Comparison is case-insensitive.

Source

pub fn is_single_byte(self) -> bool

Returns true if this is a single-byte encoding (includes ASCII).

Source

pub fn codepage(self) -> Option<&'static [u16; 128]>

Return the codepage table for single-byte encodings, if one exists. The table maps bytes 0x80–0xFF (index = byte - 0x80) to Unicode codepoints.

Trait Implementations§

Source§

impl Clone for Encoding

Source§

fn clone(&self) -> Encoding

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Encoding

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Encoding

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Encoding

Source§

fn eq(&self, other: &Encoding) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Encoding

Source§

impl Eq for Encoding

Source§

impl StructuralPartialEq for Encoding

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.