in reply to Re: Detect wrong characters
in thread Detect wrong characters

But if you write characters that violate the encoding, they might look rather weird if your application is tuned to that encoding, but nevertheless be saved. Or am I wrong?

And an XML file with encoding='ISO-8859-1" should not contains characters in another encoding. The ideal solution to use UTF-8 unfortunately doesn't work in my environment - in the midst of a chain of production ;)

Replies are listed 'Best First'.
Re^3: Detect wrong characters
by ikegami (Patriarch) on Dec 02, 2024 at 15:27 UTC

    if you write characters that violate the encoding

    You can't write character that violate the encoding. It's simply not possible. But you could encode characters using the wrong encoding, and incorrectly write that to the XML document. This would produce a document that contains different characters than the intended characters. Detecting this would require heuristics, as per my original post.

    And an XML file with encoding='ISO-8859-1" should not contains characters in another encoding.

    No. An XML file with encoding='ISO-8859-1" can not contain characters in another encoding (unless encoded using entities such as ਩). It's simply not possible.