Function rphtml::entity::encode_with
source · [−]pub fn encode_with<F>(content: &[char], encoder: F) -> Vec<char, Global> where
F: Fn(&char) -> Option<EncodeType>,
Expand description
encode with the Encoder function.
Examples
use htmlentity::entity::*;
let html = "<div class='header'></div>";
let html_encoded = encode_with(&html.chars().collect::<Vec<char>>(), |ch:&char|{
if(EntitySet::SpecialChars.contains(ch)){
return Some(EncodeType::Named);
}
None
});
assert_eq!(html_encoded.iter().collect::<String>(), "<div class='header'></div>");
let html_decoded = decode_chars(&html_encoded);