AppCode
 
Get AppCode

Encoding

Last modified: 13 February 2023

To display and edit files correctly, AppCode needs to know which encoding to use. In general, source code files are mostly in UTF-8. This is the recommended encoding unless you have some other requirements.

To determine the encoding of a file, AppCode uses the following steps:

  • If the byte order mark (BOM) is present, AppCode will use the corresponding Unicode encoding regardless of all other settings. For more information, see Byte order mark.

  • If the file declares the encoding explicitly, AppCode will use the specified encoding. For example, this can apply to XML or HTML files. The explicit declaration also overrides all other settings, but you can change it in the editor.

  • If there is no BOM and no explicit encoding declaration in the file, AppCode will use the encoding configured for the file or directory in the file encoding settings. If encoding is not configured for the file or directory, AppCode will use the encoding of the parent directory. If the parent directory encoding is also not configured, AppCode will fall back to the Project Encoding, and if there is no project, to Global Encoding.

Different types of files use different ways to define encoding. AppCode recognizes encoding of files based on their contents.

Encoding has influence on the way AppCode reads or writes files. If a file has been modified but not yet saved, any changes in encoding affect file writing; if a file has not been modified, then reading is affected. AppCode suggests specific ways to change encoding of a file according to its type, using File Encodings Settings page, the Status bar, or the editor.