1

I'm trying to figure out what is the proper way to use the "not" operator (Negation) which looks like: ¬ (UTF-8: U+00AC) in JavaScript. I could use:

<span>¬A</span>

But I'm not sure if it is the proper way and if its been supported on all (or most) of the modern browsers and mobile. I tried to find a previous topic on this matter but could not find any. The wanted result is to display this operator beside A.

2 Answers 2

2

Correct escape sequences for HTML are: &#x00AC, followed by ';A', and for javascript - either '\xACA' or '\u00ACA'.

"meta charset" is always advisable to include, but it does not affect the escapes.

I added ';' after the HTML escape sequence: for some reason it wasn't needed if instead of 'A' there is, for example, 'k', I didn't know. Semicolon has to be added.

Sign up to request clarification or add additional context in comments.

Comments

0

If you are properly using UTF-8 (which is to say that your HTML, JS, and CSS files are all encoded in UTF-8, <meta charset="utf-8"> is present in the <head>, and HTTP headers all define the charset as UTF-8), there should be no need to encode the symbol at all. Simply write ¬, exactly as you have done here.

The only symbols you need to encode are < and & (also ' and/or " in attributes). Most would also recommend encoding > and the non-breaking space, to avoid confusion. I encode all of these, but nothing else.

2 Comments

I actually encode quotation marks everywhere, not just in attributes. It does no harm, and it makes my life simpler to have only one encoding method to use everywhere.
Yes, that would be correct. I used it just once before without ';' and for some reason it worked. May be quirk. And about <meta charset="utf-8">: IIS doesn't care, but HttpListener simply doesn't work without it. Better to add and every time. - thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.