How to change character encoding for .log files?

I'm not seeing anywhere in Preferences (Mac) to do this for specific file type.

I found this:


But it doesn't let me set encoding by file type, just per directory, which isn't useful to me right now.

BTW, I've heard that UTF-8 should be used for coding files (like PHP, HTML, CSS, and JavaScript), but should I instead use ISO-8859-1? I have run into a few copy-paste issues in the past, so maybe encoding is always some sort of double-edged sword.

0
4 comments

But it doesn't let me set encoding by file type, just per directory, which isn't useful to me right now.

Unfortunately, you can't specify an encoding per an extension, please vote: https://youtrack.jetbrains.com/issue/IDEABKL-2726

BTW, I've heard that UTF-8 should be used for coding files (like PHP, HTML, CSS, and JavaScript), but should I instead use ISO-8859-1? I have run into a few copy-paste issues in the past, so maybe encoding is always some sort of double-edged sword.

Unless you know for sure that your project is using something else, I'd suggest that you go with UTF-8 in both fields.

0

Thanks for the info.

We cater to international clients and have gotten errors with json_encode and json_decode with international keyboard characters or whatever not converting properly (turning into question marks or breaking the format etc), so I'm not sure UTF-8 is viable enough.

For source code it should be (translation files can be done with another editor), but in the case of log files, it's very easy for me to copy and paste and peruse in PHPStorm than the alternatives on Mac, like TextEdit (terrible) or TextMate (not horrible) specifically because PHPStorm has sensible file text navigation keyboard shortcuts (similar to Windows and at least consistent across contexts) whereas others are all over the place and inconsistent (like when using page/line begin/end for instance which I use all the time).

So it'd be nice to find some solution or workaround for at least log files with character formatting... any other suggestions? Even just a good editor that is easy to read and work with. Notepad++ was great on Windows but I'm not finding anything as good for Mac (except for PHPStorm). Maybe I should open log files in their own project directory?

 

0

You can specify encoding for individual files there:

Encoding for current file can also be changed via status bar (changing it there adds that entry in the screenshot above):

1

I noticed I can set an encoding per folder in the project, which is good enough for log files.

However, if I set debug log files to generate in a folder with code files, I'm supposing the encoding won't negatively affect the code files as long as all of the text in them has come from my keyboard (normal American English typing).

0

Please sign in to leave a comment.