Crates.io | escape-bytes |
lib.rs | escape-bytes |
version | 0.1.1 |
source | src |
created_at | 2023-11-30 10:01:48.318683 |
updated_at | 2023-12-01 18:34:41.376482 |
description | Escapes bytes that are not printable ASCII characters. |
homepage | https://github.com/stellar/escape-bytes |
repository | https://github.com/stellar/escape-bytes |
max_upload_size | |
id | 1054050 |
size | 63,367 |
Escapes bytes that are not printable ASCII characters.
The exact rules are:
\0
.\t
.\n
.\r
.\\
.0x20
..=0x7e
is not escaped.\xNN
.Intended for use where byte sequences are not valid ASCII or UTF-8 but need to be stored in a semi-human readable form where only ASCII or UTF-8 are permitted.
let str = b"hello\xc3world";
let escaped = escape_bytes::escape(str);
assert_eq!(escaped, br"hello\xc3world");
let escaped = br"hello\xc3world";
let unescaped = escape_bytes::unescape(escaped)?;
assert_eq!(unescaped, b"hello\xc3world");
License: Apache-2.0