What does the message "Invalid byte 2 of a 3-byte UTF-8 sequence" mean?

avernet picture avernet · Jul 4, 2012 · Viewed 73.4k times · Source

I changed a file in Orbeon Forms, and the next time I load the page, I get an error message saying Invalid byte 2 of a 3-byte UTF-8 sequence. How can I solve this problem?

Answer

avernet picture avernet · Jul 4, 2012

This happens when Orbeon Forms reads an XML file and expects it to use the UTF-8 encoding, but somehow the file isn't properly encoded in UTF-8. To solve this, make sure that:

  1. You have an XML declaration at the beginning of the file saying the file is in UTF-8:

    <?xml version="1.0" encoding="UTF-8" ?>
    
  2. Your editor is XML-aware, so it can parse the XML declaration and consequently use the UTF-8 encoding. If your editor isn't XML aware, and you don't want to use another editor, look for an option or preference allowing you to specify that the editor must use UTF-8.