Monday, March 8, 2010

Quotes or inches?

Most word processing and layout programs included a feature some years ago called “smart quotes.” This feature automatically turns straight inch-marks (" ") on your computer keyboard to typographer's quotation marks (“ ”). It's so common now, most of us never think about it. But when you are setting up your eBook or Web page, you may not be using your standard word processor. Most text editors and code editors still use the inch-mark because it is a vital part of XML coding. So, you need to know the correct code to insert in your XML or XHTML document to get the right punctuation.

The first thing to know is what character-set encoding to use. When I started in eBooks about 10 years ago it was often a pain to get special characters, but about that time an encoding called “UTF-8” became common. This extended character set will enable you to retain the special characters from your word processing file and to add special characters with a simple code. The following is a code sample for the head of the XHTML in your eBook.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
</head>

Notice that in the code sample we use the inch-mark instead of typographer’s quote.

Next, you need the right characters in your eBook. If you use the utf-8 charaset, the quotation marks, em-dashes, apostrophes, and other special characters you used in your text file should render correctly. If you find that they are not, you need to use the actual entity from the XHTML entity list. For most characters, there is a pseudo-English name for the entity. For all characters, there is a numeric code that you can use to get the right character. Below is a chart of the most common entities in novel publishing.










EntityEntity
Displayed
NumberNumber
Displayed
Description
&amp;&&#38;&ampersand
&ldquo;&#8220;left double quotation mark
&lsquo;&#8216;left single quotation mark
&rdquo;&#8221;right double quotation mark
&rsquo;&#8217;right single quotation mark
&emsp;&#8195;em space
&ensp;&#8194;en space
&nbsp; &#160; no-break space = non-breaking space
&mdash;&#8212;em dash
&ndash;&#8211;en dash
&copy;©&#169;©copyright sign
&hellip;&#8230;horizontal ellipsis = three dot leader

If you'd like a more complete explanation of entities and how to use them, Elizabeth Castro’s Character Entity References in HTML 4 and XHTML 1.0 site is the best available.

No comments:

Post a Comment