Skip to content

Should the hexadecimal representation for control chars be escaped ? #134

Answered by wooorm
bnchi asked this question in Q&A
Discussion options

You must be logged in to vote

The \f in the JavaScript string you show is an escape. Just like \n. Or \t. It is a form feed character: '\f'.charCodeAt(0).toString(16) is c.

If you type f or \\f in Rust, it’s something else. It could definitely be that \f isn‘t allowed to be typed literally in Rust, I don’t know from the top of my head.

So it’s not the same as the JavaScript test case.

I believe your test case in Rust should be:

assert_eq!(
    to(&Node::Image(Image {
        position: None,
        alt: String::new(),
        url: String::from("\x0C"),
        title: None
    }))
    .unwrap(),
    "![](<\x0C>)\n",
);

If I put this correctly the test above is actually unit testing a "hand written" AST object where a …

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@bnchi
Comment options

@wooorm
Comment options

Answer selected by bnchi
@bnchi
Comment options

@wooorm
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants