How to set default encoding for a project?


I want to set the default encoding for all new files in PhpStorm to be UTF-8.

In FIle... Settings... (Under Project Settings)... File Encodings I have set IDE encoding and project Encoding to be UTF-8.

However new files (e.g. test.html) are created with a encoding of ISO-8859-1.

This in on PHP Storm 6.0 on Windows 7.

I must be missing something?


--Justin Wyllie

Comment actions Permalink

Hi there,

Please try restarting PhpStorm after changing default project encoding.

Comment actions Permalink

Hi Andriy

Thanks. Well I hadn't done it correctly - but now that I have and re-start it still doesn't work.

I go File... Settings... File Encodings.

I see a split panel which says File/Directory on the left. On the right it says Default Encoding.

My project folder structure is shown in the left panel.

I navigate through this and select a directory. In the right panel I select UTF-8 from a drop-down.

I close and re-start PHPStorm.

I create a new .html file in the directory I chose above. (Manually not by choosing HTML file from the options offered by PHP Storm).

I select the FIle in the File explorer and click File... File Encoding. It appears to show the file is ISO-8859-1

However; the File may in fact be in UTF-8. I enter a UTF-8 £ sign. Save the file. Open it in FireFox and FireFox detects the Encoding as UTF-8 and displays the £ sign correctly. (If the file was ISO-8859-1 I would need to set that to be the encoding to get the £ sign to display correctly). So; am I simply mis-reading the File... Encoding feature? It sets the encoding on an indivdual file but does not show the current encoding? If so; how would I detect the encoding of a file?



Comment actions Permalink

TBH I do not know what problem you are facing (I mean -- why it bahaves this way for you).

This is how I've got it set up for every project -- works fine (UTF-8 detected by default for all files).
If you are doing testing -- do it on brand new empty project. Who knows .. but already configured projects may have some settings that force IDE to behave your way.

Comment actions Permalink

I have same problem. I want see Project Encoding -> UTF-8 by default.

But, if a create new app, i will see in Settings: Project Encoding -> Windows-1251

Why? Where I can change default value of ProjectEncoding?

Comment actions Permalink

@Ildar Asanov

Try File | Other Settings | Settings for New Projects...

Comment actions Permalink

@Andriy Bazanov

Thanks, it works! 💪🙏


Please sign in to leave a comment.