Portable SIMD escaping with reusable ASCII tables, HTML, HTML5, JSON, and LaTeX presets ported from v_escape
///|
test "HTML5 preserves slash and Unicode" {
assert_eq(@escape.html5.escape("<😀 & />"), "<😀 & />")
}///|
test "custom table and lazy formatting" {
let escaper = @escape.Escaper::new([(b'<', "<"), (b'\"', """)])
assert_eq(escaper.escape("Hello,< world!\""), "Hello,< world!"")
let escaped = @escape.json.escape_fmt("a\nb")
assert_eq("[\{escaped}]", "[a\\nb]")
}pub struct Escaped {
// private fields
}pub struct Escaper {
// private fields
}test {
assert_eq(@escape.html5.escape("<😀 & />"), "<😀 & />")
assert_eq(@escape.json.escape("a\n\"b"), "a\\n\\\"b")
}test {
let escaped = @escape.html5.escape_fmt("<a>")
assert_eq("value: \{escaped}", "value: <a>")
assert_eq(escaped.to_string(), "<a>")
}fn Escaper::escape_string(self : Escaper, input : StringView, output : StringBuilder, algorithm? : Algorithm) -> Unittest {
let escaper = @escape.Escaper::new([(b'<', "<"), (b'\"', """)])
assert_eq(escaper.escape("Hello,< world!\""), "Hello,< world!"")
}fn simd_available() -> BoolInstall
Download zipPortable SIMD escaping with reusable ASCII tables, HTML, HTML5, JSON, and LaTeX presets ported from v_escape