I changed the html file, saved it, and then the server started to swear (I use Thymeleaf and Spring):

org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 19; An invalid XML character (Unicode: 0x0) was found in the element content of the document. 

Thank you for having some kind of experience in PHP, where there were similar problems and I immediately thought on the BOM and removed it from Notepad. Why does Idea do it at all? Previously, if you save this, it was not, now it is (did not change anything in the settings), that is, from this and that this problem appeared. How to remove it?

    1 answer 1

    In general, figured out. Firstly, Thymeleaf (although it may not be the case) is quite picky about the encodings. Secondly, Idea as soon as it sees in the html file the charset immediately tries to save the file in this format. Here it only works upwards. If there was UTF-8 and we recorded UTF-16, the medium will help us by re-saving the file in UTF-16 format. But if we return UTF-8, then the file is no longer converted. Probably according to the logic that UTF-8 will fit into UTF-16, and UTF-16 will not fit into UTF-8. Peculiar of course.

    Who will have the same problems with the encoding. Make sure everything is in the same format. If you have HTML in UTF-8 format and you use localization from the properties file, then this file must also have UTF-8 encoding! (The default is windows-1251, and the rest of the files have a default of UTF-8). Go to the File encoding menu via Settings and set everything up there.

    In general, once again I notice that all this "automation" only interferes. Allows you to stumble on a rake and play around with errors from the air.