How can I eliminate these useless character sets

when I start from from_utf8_lossy reads the content and converts it to string. I find some strange symbols

Is there any way for the rust standard library?

let resp_data = String::from_utf8_lossy(&res);



\n0\b\u0002\u0012*test-2022-06-18 15:08-阳性\u0018*

Output effect I want:

test-2022-06-18 15:08-阳性

That means your string wasn't UTF-8 to begin with.


You need to fully parse your input to just the parts that are actual text.

This is the method I input to save data

pub async fn save_nucleic_ipfs(data: NucleicAcidsDto) -> String {

    let symbol = String::from("-");
    let mut req_data = String::new();

    if let Some(name) = {

    // data transform
    let date: String = Local::now().format("%Y-%m-%d %H:%M").to_string();

    if let NucleicAcidsEnum::NEGATIVE = data.result {
    if let NucleicAcidsEnum::POSITIVE = data.result {

    let client = ipfs::coon();
    let ipfs_data = Cursor::new(req_data);

    match client.add(ipfs_data).await {
        Ok(res) => res.hash,
        Err(e) => String::from("Save nucleic acid error"),

The question is, what byte sequence ends up inside res in your first code sample? Is it essentially a result of some_string.as_bytes(), or something more complicated?

Maybe ask the question in a Chinese forum,, could be better.

I guess it might be something with gbk and utf8.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.