PhpStorm: Converting folders encoding to another

12,650

Solution 1

AFAIK it's not possible to do this for whole folder at a time .. but it can be done for multiple files (e.g. all files in certain folder):

  1. Select desired files in Project View panel
  2. Use File | File Encoding
  3. When asked -- make sure you choose "convert" and not just "read in another encoding".

You can repeat this procedure for each subfolder (still much faster than doing this for each file individually).


Another possible alternative is to use something like iconv (or any other similar tool) and do it in terminal/console.

Solution 2

Watch out when opening the file inPHPStorm that you want to convert. In my case all the files were still encoded in ISO-8859 but opened in UTF-8 resulting in misspelled umlauts i.e. In this case direct conversion to UTF-8 is not possible.

If you encounter this do following:

  1. Open the ISO-8859 file
  2. Change file encoding dropdown (lower right corner) to ISO-8859-1 or ISO-8859-15 and choose REOPEN
  3. Misspellings will now disappear
  4. Then change the encoding again (dropdown lower right corner), this time to UTF-8 and choose CONVERT
  5. Now the file is properly encoded in UTF-8

cheers

Share:
12,650
Elven
Author by

Elven

Updated on June 14, 2022

Comments

  • Elven
    Elven almost 2 years

    I have project, where are lots of files in ISO-8859-15 and I need to convert them to UTF-8. If I change one file, it asks "Do you want to convert - plaplapla", if I say yes, important symbols wont become ???.

    However, since my project file amount is HUGE, I cannot do that one by one. Changing encoding settings from project settings, it might change encoding to utf-8 but all the symbols will become ??? (thus no conversion).

    So, how can I tell PhpStorm to convert all files into utf-8? Is it possible and if yes, how? What is the alternative method?