1

I am trying to force PhpStorm to encode newly created files as UTF-8, instead of Windows-1252 (which seems to be the default).

I know I can set "Project encoding" in "settings/editor/file encodings", which sets the default encoding for all newly created files in the current project.

However I'd like to set default encoding for new projects, so I will not have to change it every time I create a new project. I've searched far and wide on the internets, but with no success.

Do you guys know how to set file encoding for new projects?

Thanks in advance.

Kalko
  • 406
  • 3
  • 11
  • The IDE uses the default of the underlying operation system. And indeed many installations of MS-Windows still use totally outdated 8-bit encodings (like Windows-1252, which is close to ISO-latin1). Check if ou can switch the operating systems settings, so your file systems default encoding. – arkascha Feb 13 '17 at 10:41

2 Answers2

2

When creating new projects, you can set a proper IDE Encoding, its right next to the Project Encoding:

File Encodings PHPStorm

When you edit an existing project, it automatically recognizes the current encoding and offers you to convert/reload the project in a proper encoding.

Xatenev
  • 6,383
  • 3
  • 18
  • 42
  • I have IDE Encoding set to UTF-8, but whenever I create a new project, it is always created with Project Encoding - Windows 1252 – Kalko Feb 13 '17 at 12:04
2

All available settings that are used as defaults for newly created projects can be set at File | Default Settings....

https://www.jetbrains.com/help/phpstorm/2016.3/accessing-default-settings.html

You can also access them directly from Welcome screen -- will be just Settings under Configure drop down (could be called Preferences on Mac -- cannot verify that as I have no Mac). But in this case default settings will be mixed with IDE-wide settings as well.

In both cases the options you need to change will be under Editor | File Encodings.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • I have to try it out, but it seems this is exactly what I was looking for. Thank you very much, you saved me a lot of trouble. (I always remember to set it to UTF-8 only after some file gets messed up by the wrong encoding :D ) – Kalko Feb 13 '17 at 12:05
  • It works -- I did set it up few years ago and still got UTF-8 in all new projects. – LazyOne Feb 13 '17 at 12:10