Escape sequence for " symbol - mistake in the book

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Escape sequence for " symbol - mistake in the book

maverick
Chapter 10, pg. 208 says:

Four of the symbols used in the Jack Language (<,>,",&) must be escaped for XML.

However, my understanding is that " is not a symbol used by the Jack language

Is this a typo in the book?
Reply | Threaded
Open this post in threaded view
|

Re: Escape sequence for " symbol - mistake in the book

WBahn
Administrator
What about

let s = "Hello World";
Reply | Threaded
Open this post in threaded view
|

Re: Escape sequence for " symbol - mistake in the book

maverick
Right, I understand they are used by the Jack language for string constants, but when converting Jack to XML in this project, we are told to eliminate the double quotes. So I'm just wondering why the book talks about escaping double quotes when they do not appear in our XML file at all
Reply | Threaded
Open this post in threaded view
|

Re: Escape sequence for " symbol - mistake in the book

dolomiti7
This post was updated on .
You are right, the double quotes would be eliminated from the  string literal, however symbols like <,> and & can occur and would be illegal XML syntax.
For example:

if (x < 5) ...

The < symbol should be represented as
<symbol> &lt; </symbol>

Since < and > is exclusively used to indicate opening and closing of hierarchies in XML. Same goes for & which is an escape symbol, so it has to be escaped as well.
Reply | Threaded
Open this post in threaded view
|

Re: Escape sequence for " symbol - mistake in the book

maverick
Thank you. I appreciate the discussion about a very minor question!