39 releases
Uses new Rust 2024
| 0.17.0 | Apr 25, 2026 |
|---|---|
| 0.15.8 | Aug 5, 2022 |
| 0.15.7 | Jul 27, 2022 |
| 0.14.1 | Oct 12, 2021 |
| 0.3.2 | Dec 27, 2018 |
#139 in Hardware support
691,092 downloads per month
Used in 497 crates
(47 directly)
69KB
1K
SLoC
v_htmlescape
The simd optimized html escape code
Quick start
use v_htmlescape::escape_fmt;
print!("{}", escape_fmt("foo<bar"));
lib.rs:
autogenerated by v_escape_codegen@0.2.1
v_htmlescape
Autogenerated escape crate produced by
v_escape_codegen on top of the
v_escape-base runtime.
Behavior
Each call rewrites the characters listed in the table below into their
replacement string; every other byte of the input is forwarded verbatim.
All public entry points take a &str (UTF-8 guaranteed at the type level),
so they cannot be used to construct invalid UTF-8.
Escape table
| Byte (hex) | Source | Replacement |
|---|---|---|
0x22 |
" |
" |
0x26 |
& |
& |
0x27 |
' |
' |
0x2F |
/ |
/ |
0x3C |
< |
< |
0x3E |
> |
> |
Public API
The following functions are emitted, gated by their respective Cargo features (all enabled by default):
| Function | Feature | Signature |
|---|---|---|
escape_string |
string |
fn(&str, &mut String) |
escape_bytes |
bytes |
fn(&str, &mut Vec<u8>) |
escape_fmt |
fmt |
fn(&str) -> impl Display + '_ |
At runtime the implementation dispatches to the best SIMD backend
available on the current CPU (AVX2/SSE2 on x86_64, NEON on aarch64,
simd128 on wasm32) and falls back to a scalar loop otherwise.