#### 30.5.2 Mapping individual special characters

To force a mapping different from the DITA2Go mapping of a particular character, or to map any arbitrary Unicode character (for example):

    [CharConvert]
    ; Unicode char num = HTML numeric value or string replacement
    ; nonbreaking hyphen is decimal 8209, becomes entity &#150;
    8209 = 150
    ; em space is x2003, becomes three nonbreaking spaces
    x2003 = &nbsp;&nbsp;&nbsp;

Character to replace

To the left of the equals sign, specify any of the following for the character you want to replace:

- the decimal ASCII character code
- the decimal Unicode character number
- x followed by the hexadecimal code for the character
- u+ or U+ followed by the hexadecimal code for the character
- the character itself, if it is one of the following:
  - a character in the printable set other than the asterisk (*) or question mark (?), both of which DITA2Go treats as wildcards unless you disable this feature; see §4.1.10 Specifying how to treat cases, spaces, and wildcards
  - a high ASCII character (decimal code 128 through 159).

Table 30-2 shows the Unicode or other hexadecimal (and in some cases, decimal) value you can specify to the left of the equals sign.

Table 30-2 Special characters to replace for HTML/XML output

Category | Character to replace | Unicode/Hex | ASCII decimal
Quote marks | Low single quote |
    x201A
    130
Left single quote |
    x2018
    145
Right single quote |
    x2019
    146
Low double quote |
    x201E
    132
Left double quote |
    x201C
    147
Right double quote |
    x201D
    148
Spaces | Hard space |
    x00A0
    160
En space |
    x2002
    ---
Em space |
    x2003
    ---
Numeric (figure) space |
    x2007
    ---
Thin space |
    x2009
    ---
Dashes | En dash |
    x2013
    150
Em dash |
    x2014
    151
Hyphens | Discretionary hyphen |
    x00AD
    173
Nonbreaking hyphen |
    x2011
    ---
Wildcards | Asterisk |
    x002A
    042
Question mark |
    x003F
    063
Miscellaneous | Bullet |
    x2022
    149
Fraction bar |
    x2044
    ---
Paragraph symbol |
    x00B6
    182
Section symbol |
    x00A7
    167

Replacement character

To the right of the equals sign, specify any of the following:

- the decimal ASCII character code for the replacement character
- x followed by the hexadecimal code for the replacement character
- a string, which can include HTML code and DITA2Go macro references.

When you supply a string rather than a character code, DITA2Go expands any macros referenced, but includes the rest of the string in the output as is. Therefore you must escape any literal characters such as < by providing an entity reference instead; in this case, &lt;.

Examples

To map the bullet to a middle dot:

    [CharConvert]
    149 = 183

To map the bullet to a bold middle dot:

    [CharConvert]
    149 = <b>&#183;</b>

To map the bullet to an image:

    [CharConvert]
    149 = <img src="mybullet.gif">

To map the ohm symbol from Unicode to the Symbol font for HTML Help:

    [CharConvert]
    U+2126 = <span class="Symbol">W</span>

and add the class to your CSS:

    [CSSEndMacro]
    .Symbol {font-family: Symbol; }

In code-page encoding, as for HTML Help output, the only valid solution for handling out-of-range characters is to use a font that has the desired glyph within the code page. In this case, the glyph for ohm is in Symbol, which will work in all single-byte code pages (but not in Asian code pages, where an Asian symbol font is needed instead).

Use only to map non-printable characters

Although you can specify any decimal integer to the left of the equals sign, this mapping option is intended only for characters that are not in the regular printable set. Using [CharConvert] to map a character in the printable set can result in surprises. You can try mapping other integers, but the odds are poor for values not in the range 128 through 255. There are a few exceptions. For example, DITA2Go automatically converts a solidus to a forward slash, which is in the printable set. You can prevent this conversion by mapping the solidus to itself, specifying the Unicode value to the left of the equals sign and again on the right, as a numeric entity reference:

    [CharConvert]
    8260 = &#8260;

Previous Topic: 30.5.1 Converting Western European accented characters

Next Topic: 30.5.3 Avoiding use of special characters in URIs

Parent Topic: 30.5 Mapping special characters

Sibling Topics:

30.5.1 Converting Western European accented characters

30.5.3 Avoiding use of special characters in URIs

30.5.4 Preventing character mapping

Table of Contents • Index