blob: f50cf88e543f43f0543d2e3f901e235e2efdbe3c [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
--><mediawiki xmlns="http://www.mediawiki.org/xml/export-0.3/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="0.3" xml:lang="en" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.3/ http://www.mediawiki.org/xml/export-0.3.xsd">
<siteinfo>
<sitename>NetBeans Wiki</sitename>
<base>http://wiki.netbeans.org/Main_Page</base>
<generator>MediaWiki 1.15.1</generator>
<case>first-letter</case>
<namespaces>
<namespace key="-2">Media</namespace>
<namespace key="-1">Special</namespace>
<namespace key="0"/>
<namespace key="1">Talk</namespace>
<namespace key="2">User</namespace>
<namespace key="3">User talk</namespace>
<namespace key="4">NetBeans Wiki</namespace>
<namespace key="5">NetBeans Wiki talk</namespace>
<namespace key="6">File</namespace>
<namespace key="7">File talk</namespace>
<namespace key="8">MediaWiki</namespace>
<namespace key="9">MediaWiki talk</namespace>
<namespace key="10">Template</namespace>
<namespace key="11">Template talk</namespace>
<namespace key="12">Help</namespace>
<namespace key="13">Help talk</namespace>
<namespace key="14">Category</namespace>
<namespace key="15">Category talk</namespace>
</namespaces>
</siteinfo>
<page>
<title>DevFaqI18nFileEncodingQueryObject</title>
<id>7315</id>
<revision>
<id>39304</id>
<timestamp>2010-06-16T14:13:35Z</timestamp>
<contributor>
<username>Vstejskal</username>
<id>363</id>
</contributor>
<comment>/* Project Encoding vs. File Encoding - What are the precedence rules used in NetBeans 6.0? */</comment>
<text xml:space="preserve">__NOTOC__
===Project Encoding vs. File Encoding - What are the precedence rules used in NetBeans 6.x? ===
NetBeans implements the FileEncodingQuery object (FEQ) to determine the language encoding for projects and files. The '''FEQ''' is an interface for obtaining information about which encoding should be used for reading from/writing to a particular file. It can be best defined as a ''layer model'' that adheres to the following precedence rules (level of importance from top to bottom):
* '''file FEQ'''
* '''project FEQ'''
* '''fallback FEQ'''
For example:
# When the client requests the FEQ for the encoding of some object, it first asks the file FEQ. E.g., when the file is XML or HTML, it looks inside the file and returns either the declared encoding attribute, otherwise &lt;tt&gt;null&lt;/tt&gt;. If the file FEQ is not &lt;tt&gt;null&lt;/tt&gt;, the value is returned to the client, otherwise it continues:
# If the file resides within a project that has implemented the FEQ, a request is made for the project FEQ. If the project FEQ is not &lt;tt&gt;null&lt;/tt&gt;, the value is returned to the client, otherwise it continues:
# If neither the file FEQ nor project FEQ cannot provide any encoding information, the fallback FEQ is used. The fallback FEQ returns the language encoding used by the operating system (i.e. &lt;tt&gt;Charset.defaultCharset()&lt;/tt&gt;).
For JSP pages, the JSP parser is responsible for determining the encoding value. For example: if the file itself doesn't contain the encoding declaration, the parser looks in &lt;tt&gt;web.xml&lt;/tt&gt;. If there is no declaration there either, it returns ISO-8859-1.
====What if the project encoding is not set (i.e. for projects that have not implemented the FEQ)?====
The fallback FEQ is applied (i.e. the encoding of the system locale). This applies to imported projects and projects created in NetBeans versions 5.x and prior.
'''Note''': This does not have any impact on the global project encoding value, which is still used for the creation of new NetBeans 6.x projects, and is by default UTF-8. Nor does this affect the encoding value of previously created NetBeans 6.x projects created during the same session, or opened projects created from previous sessions.
====What project or file types have/have not implemented FEQ for NetBeans 6.x?====
'''Project Types'''
* Most NetBeans 6.x project types have implemented FEQ (this includes Ruby and Rails projects).
* The NetBeans Modules project type uses UTF-8 and it is not possible to change the encoding for this project type.
* UML does not have a project encoding property for NetBeans 6.x, and uses the encoding of the system locale. For UML Java projects that have been reverse-engineered or have had their code generated, the FEQ is applied to query for file encoding. If no information is returned, the encoding of the system locale is used.
'''File Types'''
* The seeding of encoding for JSP, HTML, and XML files has been completed. For XML it has been completed for most XML-based file types that can be created using the New File wizard, but not for all XML files created by projects for internal data. Other XML files created and used by various projects (e.g. &lt;tt&gt;web.xml&lt;/tt&gt;, &lt;tt&gt;sun-config.xml&lt;/tt&gt;) still use UTF-8; it has currently not been decided whether these files should use the encoding applied to the value of the project encoding or not.
* The Visual Web index page currently has the encoding value seeded according to the project encoding value.
* Properties files have a special encoding defined which translates between escape sequences and real characters. During saving, all non-ASCII characters are translated to the corresponding &lt;tt&gt;\u....&lt;/tt&gt; sequences and than the result is saved using encoding ISO-8859-1 (aka Latin 1). During loading, the decoding process is reverse - the file is first decoded using the ISO-8859-1 encoding and then it is parsed such that the &lt;tt&gt;\u....&lt;/tt&gt; sequences are recognized and translated back to the corresponding Unicode characters. This special encoding cannot be changed.
-----
Applies to: Netbeans 6.x
Platforms: All
See also:
[[FaqI18nProjectEncoding| How do I set or modify the language encoding for a project?]]</text>
</revision>
</page>
</mediawiki>