0
Fixed

xml files open with wrong encoding

Fritz Weisshart 10 years ago updated by Alexander Blach (Developer) 10 years ago 4
Hi,
Textastic Mac opens utf-8 encoded xml files as Western (ISO Latin 1), although utf-8 is set as default in Textastic.
I have to manually reopen any xml file as utf-8 to get the proper display.

Answer

Answer
Fixed
Thanks for the example file. The encoding routine didn't properly handle the standalone attribute that follows the encoding attribute in the XML header. 

This bug will be fixed in the next update.
Under review
Hello,

this is how the encoding is detected:

Textastic first tries to detect the file encoding by reading the "com.apple.TextEncoding" extended attribute from the file system. This attribute is set by some apps like TextEdit (and Textastic).

If there is no extended attribute, it tries to read the Byte Order Mark (BOM).

If there is no BOM, it tries to detect the text encoding from the actual file data: To detect encodings of HTML or XML files, it first tries to find "charset=" or "encoding=" strings in the file and uses the encoding specified there. Does your XML file contain "charset=" or "encoding=" strings?

If none of the above worked, UTF-8 is tried.

If UTF-8 does not work, it tries some other encodings like ISO-Latin-1.
Hi Alex,

Default in TextEdit and Textastic is set to UTF-8

This is my file header:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
The file has no BOM
Hi,

the default encoding is only used when creating new files. Opening existing files detects the encoding as described above.

Can you please send me the XML file to support@textasticapp.com so I can try it here?
Answer
Fixed
Thanks for the example file. The encoding routine didn't properly handle the standalone attribute that follows the encoding attribute in the XML header. 

This bug will be fixed in the next update.