arrays - 在 Rust 中将 u8 数组转换为 base64 字符串

标签 arrays string rust type-conversion base64

我在 Rust 中有一个 u8 数组。我将如何将它们转换为表示它们为 base64 的 String

最佳答案

您正在寻找的是 base64 箱子,尤其是它的 encode()功能。用法是 pretty straightforward :

extern crate base64;

fn main() {
    let data: Vec<u8> = vec![1,2,3,4,5];
    println!("{}", base64::encode(&data))
}

关于arrays - 在 Rust 中将 u8 数组转换为 base64 字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58051863/

相关文章:

c++ - 从 cin 读入结构数组时终止输入

c - 为什么我的 char 数组有一半是空白?

c - 如何将作为宏操作结果的宏字符串化?

rust - 如何将迭代器适配器与返回impl Trait作为IntoIterator的IntoIter关联类型的函数一起使用?

rust - 为什么使用 LTO 会增加我的 Rust 二进制文件的大小?

rust - 如何模式匹配 Box 以获取结构的属性?

javascript - 数组数组的 JS 子集

javascript - 排序 "day" "week" "month"和 "year"

python - 有效地查找 numpy 数组中二进制字符串中的位位置

c++ - 在这种情况下,我将如何循环遍历所有各种可能性?