Curly quotes, straight quotes, and copy/pasting from the ebook

I am working on an update of the ebook for the extended ebook version (includes videos!) and I would love it if anyone has any errors to report. If you can get them to me (comments, emails, carrier pigeon, whatever!) before the end of March I can get them corrected for the next version.

One thing I discovered today is that if you copy and paste code samples directly from the ebook, you may have trouble. Word, as some of you may know, likes curly quotes like “ and ” but PHP (and JavaScript and HTML and almost every other code type) does not like curly quotes. When I wrote the book I turned off curly quotes because of this, but my editors have them on by default, and despite my best efforts some have slipped into the code samples.

This shouldn’t matter if you’re just copying the code by typing it in or if you use the samples I’ve added to this site (note, not the PDFs). But if you copy and paste from an ebook version, you may run across this problem. It’s especially annoying as these quotes are impossible to see in many font faces.

I recommend, if you do copy code from the ebook versions, that you do a search and replace across it, replacing and with ".

I’m making a note of this in the code samples as I find them in the ebook, but it’s very hard to see and I probably won’t find all of them. (I wonder if I can search and highlight in the PDF?? hmmmm…)

I know it’s a problem in the code at the top of page 76 (in the “Making Rollovers with jQuery” section). It should read:

  $("#link1 img").hover(
    function() {
      this.src = this.src.replace("_off","_on");
    },
    function() {
      this.src = this.src.replace("_on","_off");
    }
  );
});
</script>
</head>
<body>
<a id="link1" href="#"><img src="images/get-scifi_off.png" alt="Get Science
Fiction!"></a>
</body>
</html>

Honestly? I really hate Word. I’d rather write NOTHING in that editor, because it causes me much more grief than it solves. I’m sure my editors would disagree.

6 thoughts on “Curly quotes, straight quotes, and copy/pasting from the ebook

  1. The problem I reported was not in any eBook. It was in your website, right here. I do not own the eBook. I have the printed version. It was copying bad code from your book that made me come to your website to copy code to see if I had an error. The code here is where the curly quotes were introduced.

    1. Okay can you tell me what chapter you were looking at the code samples where you found this? So I can go fix it? I’m now looking at all the downloadable files again to make sure that curly quotes are driven to oblivion, but if I know where you are I can make sure those are correct first.

      Creating the code samples was done after the book was written, and it is quite possible that I copied what looked like straight quotes from my version of the ebook and they ended up as curly quotes here.

      1. How many times must I repeat myself? Chapter 2, the code for figure 2.2. I have mentioned this 3 times now. I am unaware where else you have errors like this. Given your poor research and reading of my comments, I can assume there is more elsewhere…

Leave a Reply

Your email address will not be published.