mxmlextrema_as3parser/util/
escaping.rs

1/// Escapes XML special characters.
2pub fn escape_xml(characters: &str) -> String {
3    let escaped = htmlentity::entity::encode(characters.as_ref(), &htmlentity::entity::EncodeType::NamedOrHex, &htmlentity::entity::CharacterSet::SpecialChars);
4    String::from_utf8_lossy(&escaped.bytes().into_owned()).into_owned()
5}
6
7/// Unescapes XML entities conforming to HTML entities.
8pub fn unescape_xml(input: &str) -> String {
9    let unescaped = htmlentity::entity::decode(input.as_ref());
10    String::from_utf8_lossy(&unescaped.bytes().into_owned()).into_owned()
11}