Text file encoding - putting encoding info directly within files for non XML/HTMLs

Answered

Hi,

I got legacy project which uses template files that were created using ISO-8859-2 encoding. Now we have branch where the whole system is changed to use UTF8, so all the files are converted to UTF8 as well. The problem is that when I switch between these branches IntelliJ keeps thinking that some text files are UTF8 even when I switched to legacy branch where they were ISO-8859-2. How can I plant the encoding information into that file, even for files that are not supporting by format (like XML or HTMLt). Let say I got plain text file (with "odd" file name extension) but as it is parsed by our software prior use I am able to put any comment blocks into it with any content I want with no problem. So if I could put something that IntelliJs would understand that would be great. But I cannot find anything and docs just talk about XML/HTML https://www.jetbrains.com/idea/help/configuring-individual-file-encoding.html#edit

Any hints appreciated. Thanks in advance.

3 comments

If you configure custom encoding per file/directory, it's stored in a project. You need to commit the project files so that IDE knows the encoding after checkout: https://intellij-support.jetbrains.com/hc/articles/206544839.

0

Thanks for your answer. We try to keep all the IDE related files out of the repo as not everyone must be using the same IDE. So my question here is rather - how to tell IntelliJ the encoding other way? I tried i.e. to fool it with following in my comment block

<meta charset="ISO-8859-2">

but it does not seem to do the trick.

 

0

There is no other way to tell the encoding for files that don't support it like XML/HTML.

0

Please sign in to leave a comment.