17 个版本
0.5.1 | 2024年7月16日 |
---|---|
0.5.0 | 2023年6月23日 |
0.4.8 | 2023年4月29日 |
0.4.7 | 2023年2月1日 |
0.3.0 | 2016年6月10日 |
#64 在 解析器实现
230,515 每月下载量
在 162 个 crate (18 直接使用) 中使用
35KB
656 行
quoted-printable
一个 quoted-printable 解码器和编码器。
API
quoted-printable 目前公开了三个函数
decode<R: AsRef<[u8]>>(input: R, mode: ParseMode) -> Result<Vec<u8>, QuotedPrintableError>
encode<R: AsRef<[u8]>>(input: R) -> Vec<u8>
encode_to_str<R: AsRef<[u8]>>(input: R) -> String
使用 R: AsRef<[u8]>
意味着你可以传入各种类型,包括: String
, &String
, &str
, Vec<u8>
, &Vec<u8>
, &[u8]
, Box<[u8]>
, Arc<[u8]>
decode 函数可以将 quoted-printable 字符串转换为解码后的字节,如 IETF RFC 2045 第 6.7 节所述。ParseMode 选项可以用来控制解码是“严格”还是“鲁棒”,如该 RFC 中的注释所示。通常你可能会使用“鲁棒”解码,因为它可以优雅地处理更多格式错误的输入。
encode 和 encode_to_str 函数显然是相反的操作,将一组原始字节转换为 quoted-printable。
无 std
这个crate支持no_std。默认情况下,该crate通过std
特性针对std。您可以通过取消激活default-features
来支持no_std
,如下所示
quoted-printable = { version = "*", default-features = false }
文档
请参阅https://docs.rs上的文档。