Encoding
To display and edit files correctly, IntelliJ IDEA needs to know which encoding to use. In general, source code files are mostly in UTF-8. This is the recommended encoding unless you have some other requirements.
To determine the encoding of a file, IntelliJ IDEA uses the following steps:
If the byte order mark (BOM) is present, IntelliJ IDEA will use the corresponding Unicode encoding regardless of all other settings. For more information, see Byte order mark.
If the file declares the encoding explicitly, IntelliJ IDEA will use the specified encoding. For example, this can apply to XML, HTML, and JSP files. The explicit declaration also overrides all other settings, but you can change it in the editor.
If there is no BOM and no explicit encoding declaration in the file, IntelliJ IDEA will use the encoding configured for the file or directory in the file encoding settings. If encoding is not configured for the file or directory, IntelliJ IDEA will use the encoding of the parent directory. If the parent directory encoding is also not configured, IntelliJ IDEA will fall back to the Project Encoding , and if there is no project, to Global Encoding .
Change the encoding used to view a file
If IntelliJ IDEA displays characters in a file incorrectly, it probably couldn’t detect the file encoding. In this case, you need to specify the correct encoding to use for viewing and editing this file.
With the file open in the editor, either select File | File Properties | File Encoding from the main menu or click the File Encoding widget on the status bar, and select the correct encoding of the file.
The list of encodings is rather large. You can use speed search to quickly find the correct encoding: start typing when the popup is open.
Encodings marked with or might change the file contents. In this case, IntelliJ IDEA opens a dialog where you can choose what to do with the file:
Reload : load the file in the editor from disk and apply encoding changes to the editor only. You will see the content changes related to the chosen encoding, but the actual file will not change.
Convert : overwrite the file with the chosen encoding.
This will add an association for the file to the file encoding settings. IntelliJ IDEA will use the specified encoding to view and edit this file.
Configure file encoding settings
Press Ctrl+Alt+S to open the IDE settings and select Editor | File Encodings .
IntelliJ IDEA uses these settings to view and edit files for which it was unable to detect the encoding and uses the specified encodings for new files. For more information, see File Encodings.
Select console output encoding
By default, IntelliJ IDEA uses the system encoding to view console output.
In the Settings dialog ( Ctrl+Alt+S ), select Editor | General | Console .
Java. Ошибка с символами русского алфавита в Intellij Idea! Поможете?
Я создаю свой проект на Java в Intellij Idea, но из-за того, что не очень разбираюсь в Intellij Idea, иногда тыкаю не туда, куда надо (._. )
Дело вот в чем. Недавно я начал добавлять в свой проект сериализацию, чтобы прогресс сохранялся на компьюторе в виде фалов формата .ser. В Intellij Idea эти файлы отображались в дереве классов и папок и в них можно было заходить. Но когда я в них заходил, я видел в этих файлах непонятные знаки и числа, а сверху надпись на английском языке про какое-то форматирование символов что-ли. Ну и короче я нажал на одну из таких и теперь при заходе на файлы .ser эти кнопки больше не появляются, а большинство странных символов отображаются в виде нормальных. Но дело в том, что именно после того, как я это сделал, мой проект перестал поддерживать латиницу и вообще большинство русских символов 🙁
Например, когда я проверяю на соответствие какую либо строку, какому либо знаку русского алфавита, вылетает такая ошибка:
Error:(447, 22) java: unclosed character literal
Вот код, если необходимо:
И даже если все строки в программе с буквами русского алфавита закомментировать или убрать, то программа запуститься, но все русские надписи на кнопках и других объектах отображаются в виде непонятных знаков и чисел.
Короче, проект в принципе перестал воспринимать русский алфавит 🙁
Не знаю, возможно это не из-за этого, но пожааалуйста, кто-нибудь из знатоков Intellij Idea, выскажите своё мнение, почему так могло произойти, потому что не очень хочется забросить проект из-за какой-то кнопки.
Заранее спасибо!
Sergey Zelenin’s blog
Столкнулся с проблемкой несоответствия кодировок ресурсных файлов и web страничек. В JSP страничке кодировка указана UTF-8, для проекта в IntelliJ IDEA тоже UTF-8, а в ресурсном файле — системная. Поэтому в моей вьюшке русские символы отображались некорректно. Понятно, что можно пофиксить с помощью утилиты native2ascii, которая находится в установленном JDK , но это приходилось бы делать каждый раз при изменении файлов.
Как пофиксить в Идее:
1. В окне настроек находим настройки File Encodings

2. Удивляемся почему для properties файлов не настроена кодировка по умолчанию и меняем Default encoding for properties files на UTF-8
3. Выбираем галочку «Transparent native-to-ascii conversion
Теперь IDEA будет автоматически переводить символы в ресурсных файлах из UTF-8 в ASCII код. В редакторе мы будем продолжать видеть русские символы:
Неправильная кодировка IntelliJ IDEA в выводе консоли
Кажется, это действительно бред, но я ничего не могу сделать со сломанной кодировкой в консоли своего IntelliJ IDEA.
Что я сделал, чтобы преодолеть это:
- Установите -Dfile.encoding=UTF-8 и -Dfile.encoding=UTF-8 как в idea.exe.vmoptions , так и в idea64.exe.vmoptions (хотя я использую 64-битную версию).
- Добавлены -Dfile.encoding=UTF-8 и -Dfile.encoding=UTF-8 для запуска/отладки конфигурации моего приложения.
- Изменены настройки > Редактор > Кодировки файлов Кодировка IDE/Кодировка проекта/Кодировка по умолчанию для файлов свойств на UTF-8.
После того, как все это сделано, удачи по-прежнему нет, и символы в консоли отображаются неправильно. Я попытался отладить метод java.io.PrintStream#println(java.lang.String) и обнаружил, что System.out.textOut.out.se.cs равно windows-1251. Не знаю, откуда берется это значение.
Эта проблема беспокоила меня в течение долгого времени, и я не мог найти ничего в Интернете, что могло бы мне помочь.