Using Different Character Sets with EditLive! for XML

Introduction

Ephox EditLive! for XML supports multiple character sets which allow it to be used in an international environment. The character set used by EditLive! for XML can be defined in one of three ways:

  1. Setting the character set via the Document.

  2. Setting the character set via the XML Configuration file.

  3. Setting the character set using the OutputCharset method of EditLive! for XML and the Visual Designer.

Note

If no character set is specified, the default will be set to UTF-8 (in accordance to XML standards)

Supported Character Sets

EditLive! for XML supports the display and usage of the following character sets:

ASCII

American Standard Code for Information Interchange

CP1252

Windows Latin-1

UTF8

Eight-bit Unicode Transformation Format

UTF-16

Sixteen-bit Unicode Transformation Format

ISO2022CN

Sixteen-bit Unicode Transformation Format

ISO2022JP

JIS X 0201, 0208 in ISO 2022 form, Japanese

ISO2022KR

ISO 2022 KR, Korean

ISO8859_1

ISO 8859-1, Latin alphabet No. 1

ISO8859_2

ISO 8859-2, Latin alphabet No. 2

ISO8859_3

ISO 8859-3, Latin alphabet No. 3

ISO8859_4

ISO 8859-4, Latin alphabet No. 4

ISO8859_5

ISO 8859-5, Latin/Cyrillic alphabet

ISO8859_6

ISO 8859-6, Latin/Arabic alphabet

ISO8859_7

ISO 8859-7, Latin/Greek alphabet

ISO8859_8

ISO 8859-8, Latin/Hebrew alphabet

ISO8859_9

ISO 8859-9, Latin alphabet No. 5

ISO8859_13

ISO 8859-13, Latin alphabet No. 7

ISO8859_15

ISO 8859-15, Latin alphabet No. 9

SJIS

Shift-JIS, Japanese

Big5

Chinese Big5.

Setting the Character Set via the Document

The character set to be used within EditLive! for XML can be specified in the document to be loaded into EditLive! for XML. To set the character set in this way the XML declaration at the start of the document must specify the character set of the document to be loaded into EditLive! for XML. This is done by specifying a value for the encoding attribute.

Example 12.1. Setting the Character Set to ASCII via the XML Declaration

<?xml version="1.0" encoding="ASCII"?>

Setting the Character Set via the XML Configuration

A meta tag explicitly specifying the character encoding can be entered into the XML configuration file for the Visual Designer. For example, to specify character encoding of ASCII, the following tag should be entered between the document tags of the configuration file as such:

<editLive>
  <document> 
    <html> 
      <head> 
        <meta 
          content="text/html;
          charset=ASCII" 
          http-equiv="Content-Type"
        /> 
        ... 
      </head> 
    ...
    </html> 
  </document> 
  ... 
</editLive>

Note

If character encoding is specified in the configuration file then this will be the final character encoding used. If an instance of the Visual Designer uses the OutputCharset method the character encoding will still be set to the value specified in the configuration file.

In order to set the character set for EditLive! for XML via the XML file the character set must be specified in the <meta> element. For more information on the <meta> element and other XML elements see the EditLive! for XML XML Reference.

Setting the Character Set using the OutputCharset method

Using this method with the Visual Designer specifies both the character encoding for the XML components in the XSL, as well as the XHTML character encoding for document the XSL will generate. For example, if specifying character encoding ASCII for an instance of the Visual Designer, called vdesigner, in JavaScript:

vdesigner.setOutputCharset("ASCII");

The XSL generated will contain the following tags:

    <?xml version="1.0" encoding="ASCII"?>
    ...
    <xs:template match="/">
        <html>
            <head>
                <link href="stylesheet.css" rel="stylesheet"
                   type="text/css"/>
                <meta content="EditLive! for XML 3.0.0.123"
                   name="generator"/>
                <meta content="text/html; charset=ASCII"
                   http-equiv="Content-Type"
                   xmlns="http://www.w3.org/1999/xhtml"/>
            </head>
            <body>
           ...
            </body>
        </html>
    </xs:template>

Using this method with an instance of EditLive! for XML will specify the character encoding the XML generated. For example, if specifying the character encoding as ASCII the XML will be defined as follows:

<?xml version="1.0" encoding="ASCII"?>

For more information on the OutputCharset method see the OutputCharset section of the instantiation APIs in this SDK.

Summary

The character set for use with an instance of EditLive! for XML can be specified within the document loaded into EditLive! for XML, through the configuration file used with EditLive! for XML or by using the OutputCharset method.