blob: 3c9713a03695347b4f1ebde898d1ff3677d3d693 [file] [log] [blame]
<?xml version="1.0" encoding="utf-8"?>
<!--Arbortext, Inc., 1988-2005, v.4002-->
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="specifyingxmlencoding" xml:lang="en-us">
<title>Specifying XML encoding</title>
<titlealts>
<searchtitle>Specifying XML encoding</searchtitle>
</titlealts>
<shortdesc>The encoding attribute specifies the character encoding set that
is used for your XML related documents (DTDs, XML files, and XML schemas).
Changing this attribute causes any new XML, DTD or XML schema that is created
with a corresponding "New..." wizard to use the selected encoding.</shortdesc>
<prolog><metadata>
<keywords><indexterm>XML files<indexterm>specifying <indexterm>encoding</indexterm></indexterm></indexterm>
<indexterm>Document type definitions (DTDs)<indexterm>specifying <indexterm>encoding</indexterm></indexterm></indexterm>
<indexterm>XML schemas<indexterm>specifying <indexterm>encoding</indexterm></indexterm></indexterm>
</keywords>
</metadata></prolog>
<taskbody>
<context><p>The default XML encoding value is UTF-8.</p><p>To change the XML
encoding value, follow these steps:</p></context>
<steps>
<step><cmd>Click <menucascade><uicontrol>Window</uicontrol><uicontrol>Preferences</uicontrol>
<uicontrol>Web and XML files</uicontrol><uicontrol>XML Files</uicontrol></menucascade>.</cmd>
</step>
<step><cmd>From the <uicontrol>Encoding</uicontrol> field, select the type
of encoding you would like to use.&nbsp;</cmd><info>Note: This encoding will
not automatically be added to any XML documents that currently exist. It will
only be added to documents you create after you select the encoding and click
<uicontrol>Apply</uicontrol>; or to existing files that you open and then
re-save after you select the line delimiter type and click <uicontrol>Apply</uicontrol></info>
</step>
<step><cmd>Click <uicontrol>Apply</uicontrol>, then <uicontrol>OK</uicontrol></cmd>
</step>
</steps>
<result><p>When you create an XML file, DTD, or XML schema, the default encoding
value will appear in the first line of the file, as shown:</p><p><codeblock>&lt;?xml version="1.0" encoding="UTF-8?></codeblock> </p><p>This
is known as the XML Declaration.</p><p>After you have created a file, you
can work in the Source view of the appropriate editor and manually edit the
encoding value if you wish to change it. When the file is saved, it will be
saved with the encoding that is specified in the encoding attribute of the
XML text declaration. If the XML declaration for the file does not contain
an encoding attribute, the encoding can only be UTF-8 or UTF-16. If it is
UTF-16, the file must begin with the proper Byte Order Mark.</p><p>If you
create an XML related document from another XML related document, the encoding
value in the source file is carried over to the new file. For example, if
you have a DTD with an encoding value of , <codeph>US-ASCII</codeph>and you
create an XML file from it, the encoding value of the XML file will also be
<codeph>US-ASCII</codeph>.</p></result>
</taskbody>
</task>