Is per-project file encoding functional?

I use UTF-8 for all new projects but I need Windows-1252 for some legacy ones. However, PhpStorm will open any file as UTF-8.

Despite what help says, the IDE seems to use "IDE Encoding" all the time, except when a file/directory exception exists, and the "Project Encoding" setting is ignored. And directory exceptions are not a sensible workaround because they are apparently not inheritable so you need to apply them to every single subdirectory (and I have hundreds of them).

So far, I fix encoding file by file as I need to edit them (using the status bar icon) but basic stuff like file search is not functional when it involves international characters.

Is per-project file encoding functional in PhpStorm 8.0.3 for Windows? Did I misread the help section?

P.S. Yes, I know I should just switch to UTF-8 and forget about any other encoding ever but I can't afford a full rewrite just to add a tiny feature.

Comment actions Permalink

Hi there,

In one of those few old projects of mine where no UTF-8 is still in use .. the inheritance seems to be fine (but then -- project was created years ago -- back in PhpStorm v0.x times).

Suggestion to try:

  • Close your project in IDE / close IDE
  • Go to the project settings folder for that project (PROJECT/.idea)
  • Open "encodings.xml" in any text editor
  • Change "useUTFGuessing" value to be "false"
  • Save file and re-open project

Any difference?

Comment actions Permalink

Thank you very much for the tip. I've edited encodings.xml to disable UTF-8 guessing and it works. I've reverted changes and it still works. I've changed project settings to remove file/directory exceptions and it keeps working. I've even created a new project from existing sources, with only a "Project encoding" value, and it works (when it's never been the case in the past).

This is plain crazy...

Comment actions Permalink

Luckily, my issue has never been as bad as in those bug reports. When I select an encodign for a given file PhpStorm remembers it.

Comment actions Permalink

Upon further testing, I can confirm that changes to the "Project Encoding" preference don't take effect until you restart PhpStorm. Reloading the project is not enough, you need a full restart. Other than that, the setting works as advertised.


Please sign in to leave a comment.