#charset #unicode #web

murdoch-charsets

provides character-sets type defined by IANA

1 unstable release

0.1.0 Jul 13, 2019

#379 in Internationalization (i18n)

MIT license

54KB
2K SLoC

crate-name at crates.io crate-name at docs.rs

murdoch-charsets

Murdoch-Charsets

murdoch-charsets provides API for name of character sets defined by Internet Assigned Numbers Authority (IANA).

In all settings, murdoch-charset provides CharacterSet traits and InvalidCharacterSetNameError.

Default Setting

By default, murdoch-charsets provides types corresponding character sets defined by IANA, and CharacterSetEnum to hold any of them.

Custom Character-Sets

You can customize the character sets by using no_charset feature

[dependencies]
murdoch-charsets = { features = [ "no_charset" ] }

then murdoch-charsets exports character_sets! macro.

character_sets!(
    UnicodeCharacterSet,
    UTF_8,                           // character-set type/variant name
    None,                            // preferred_mime_name
    "UTF-8",                         // name
    ["UTF8", "UTF_8",],              // aliases
    ["UTF-8", "UTF8", "UTF_8",],     // uppercase set of names (for FromStr)
    UTF_16,
    None,
    "UTF-16",
    ["UTF16", "UTF_16",],
    ["UTF-16", "UTF16", "UTF_16",],
    UTF_32,
    None,
    "UTF-32",
    ["UTF32", "UTF_32",],
    ["UTF-32", "UTF32", "UTF_32",],
);

By calling the macro as above, the following types and implementations of traits (Debug, Display, Copy, Clone, PartialEq, Eq, FromStr, AsRef<str>, AsRef<[u8]>) are generated.

pub struct UTF_8;
pub struct UTF_16;
pub struct UTF_32;
pub enum UnicodeCharacterSet
{
    UTF_8,
    UTF_16,
    UTF_32,
}

License: MIT

No runtime deps

Features