#[non_exhaustive]pub enum Charset {
Show 45 variants
Ibm866,
Iso8859_2,
Iso8859_3,
Iso8859_4,
Iso8859_5,
Iso8859_6,
Iso8859_7,
Iso8859_8,
Iso8859_8I,
Iso8859_10,
Iso8859_13,
Iso8859_14,
Iso8859_15,
Iso8859_16,
Koi8R,
Koi8U,
Macintosh,
Windows874,
Windows1250,
Windows1251,
Windows1252,
Windows1253,
Windows1254,
Windows1255,
Windows1256,
Windows1257,
Windows1258,
XMacCyrillic,
XUserDefined,
Latin1,
Ibm437,
Ibm737,
Ibm775,
Ibm850,
Ibm852,
Ibm855,
Ibm857,
Ibm858,
Ibm860,
Ibm861,
Ibm862,
Ibm863,
Ibm864,
Ibm865,
Ibm869,
}Expand description
a single-byte character set: the bytes below 0x80 are ASCII, the others come from its table.
The single-byte encodings of the WHATWG Encoding Standard (what browsers, HTML and mail use; whatwg())
and the DOS code pages of old files (by from_code_page or by name here; no web label names them)
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Ibm866
IBM866: DOS Cyrillic
Iso8859_2
ISO-8859-2: Latin 2, Central European
Iso8859_3
ISO-8859-3: Latin 3, South European
Iso8859_4
ISO-8859-4: Latin 4, North European
Iso8859_5
ISO-8859-5: Cyrillic
Iso8859_6
ISO-8859-6: Arabic
Iso8859_7
ISO-8859-7: Greek
Iso8859_8
ISO-8859-8: Hebrew, visual order
Iso8859_8I
ISO-8859-8-I: Hebrew, logical order (the same bytes as ISO-8859-8)
Iso8859_10
ISO-8859-10: Latin 6, Nordic
Iso8859_13
ISO-8859-13: Latin 7, Baltic
Iso8859_14
ISO-8859-14: Latin 8, Celtic
Iso8859_15
ISO-8859-15: Latin 9, Latin 1 with the euro sign
Iso8859_16
ISO-8859-16: Latin 10, South-Eastern European
Koi8R
KOI8-R: Russian
Koi8U
KOI8-U: Ukrainian and Belarusian (WHATWG’s KOI8-RU)
Macintosh
macintosh: Mac OS Roman
Windows874
windows-874: Thai (also TIS-620 and ISO-8859-11)
Windows1250
windows-1250: Windows Central European
Windows1251
windows-1251: Windows Cyrillic
Windows1252
windows-1252: Windows Western (also ISO-8859-1 and ASCII on the web)
Windows1253
windows-1253: Windows Greek
Windows1254
windows-1254: Windows Turkish (also ISO-8859-9)
Windows1255
windows-1255: Windows Hebrew
Windows1256
windows-1256: Windows Arabic
Windows1257
windows-1257: Windows Baltic
Windows1258
windows-1258: Windows Vietnamese
XMacCyrillic
x-mac-cyrillic: Mac OS Cyrillic
XUserDefined
x-user-defined: bytes 0x80..0xFF as U+F780..U+F7FF (WHATWG)
Latin1
ISO-8859-1: ISO-8859-1 exactly: each byte is its code point (the web reads the label as windows-1252) (not WHATWG)
Ibm437
IBM437: DOS United States (also ZIP names without the UTF-8 flag) (not WHATWG)
Ibm737
IBM737: DOS Greek (not WHATWG)
Ibm775
IBM775: DOS Baltic (not WHATWG)
Ibm850
IBM850: DOS Western European (not WHATWG)
Ibm852
IBM852: DOS Central European (not WHATWG)
Ibm855
IBM855: DOS Cyrillic (IBM) (not WHATWG)
Ibm857
IBM857: DOS Turkish (not WHATWG)
Ibm858
IBM00858: DOS Western European with the euro sign (not WHATWG)
Ibm860
IBM860: DOS Portuguese (not WHATWG)
Ibm861
IBM861: DOS Icelandic (not WHATWG)
Ibm862
IBM862: DOS Hebrew (not WHATWG)
Ibm863
IBM863: DOS Canadian French (not WHATWG)
Ibm864
IBM864: DOS Arabic (not WHATWG)
Ibm865
IBM865: DOS Nordic (not WHATWG)
Ibm869
IBM869: DOS Greek 2 (not WHATWG)
Implementations§
Source§impl Charset
impl Charset
Sourcepub const fn name(self) -> &'static str
pub const fn name(self) -> &'static str
its name: the WHATWG Encoding Standard’s, else IANA’s (“IBM437”, “ISO-8859-1”)
Sourcepub const fn whatwg(self) -> bool
pub const fn whatwg(self) -> bool
whether it is one of the WHATWG Encoding Standard’s encodings (the others have no web label)
Sourcepub const fn code_page(self) -> Option<u16>
pub const fn code_page(self) -> Option<u16>
its Windows code page number (None: ISO-8859-10, -14 and -16 and x-user-defined have none)
Sourcepub const fn from_code_page(cp: u16) -> Option<Charset>
pub const fn from_code_page(cp: u16) -> Option<Charset>
the character set of a Windows code page number: 437 to 869 (DOS), 874, 1250 to 1258, 10000 and 10007 (Mac), 20866 and 21866 (KOI8), 28591 to 28605 (ISO-8859; 28599, ISO-8859-9, is windows-1254 as on the web), 38598
Source§impl Charset
impl Charset
Sourcepub fn from_label(name: &str) -> Option<Charset>
pub fn from_label(name: &str) -> Option<Charset>
The character set a WHATWG label names (label, single-byte sets only): “windows-1252”,
“latin1”, “koi8-r”, “cp1251”, “iso8859-2” … The DOS code pages and the exact ISO-8859-1
have no web label: from_code_page or the variant.
Sourcepub fn decode(self, bytes: &[u8]) -> String
pub fn decode(self, bytes: &[u8]) -> String
The text of these bytes; an unassigned byte becomes U+FFFD.
Sourcepub fn decode_char(self, b: u8) -> Option<char>
pub fn decode_char(self, b: u8) -> Option<char>
The character of one byte (None: unassigned in this set).
Sourcepub fn encode_char(self, c: char) -> Option<u8>
pub fn encode_char(self, c: char) -> Option<u8>
The byte of one character (None: not in this set; the first byte where a set has two).