DNS GET return escaped?

Using unauthorised API DNS GET, I receive an escaped string rather than the normal raw string literal.

    let res = ::request::get(&url, &mut headers );
...
    println!( "\n{:?}", res.body);

example:

"<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n<meta name=\"keywords\" content=

where I want

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="keywords" content=

Is that expected and is there an obvious fix, to see the normal file unescaped?

1 Like

Standard formatter {} instead of debug formatter {:?} gives what you want.

Code:

    let res = "<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">";
    println!("Debug formatter:\n{:?}", res);
    println!("Standard formatter:\n{}", res);

Result:

Debug formatter:
"<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
Standard formatter:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
3 Likes

This topic was automatically closed after 2 days. New replies are no longer allowed.