Intellij idea как изменить кодировку проекта

Configure the encodings that IntelliJ IDEA uses to display and edit files.

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 from the main menu or click the File Encoding widget on the status bar, and select the correct encoding of the file.

    Status bar encoding

    Encodings marked with The triangle warning icon or The round error icon 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 .

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.

  1. In the Settings dialog (Ctrl+Alt+S), select .

  2. Select the default encoding from the Default Encoding list.

  3. Click OK to apply the changes.

For more information about console output settings, see Console.

Last modified: 02 November 2022

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.

The Editor | File Encodings settings

If IntelliJ IDEA can’t determine the file or directory encodings, it falls back to the configured project encoding. If there is no project, IntelliJ IDEA uses the global encoding. File or directory encodings take precedence over the project encoding, which, in turn, takes precedence over the global encoding.

For more information about handling file encodings, see Encoding.

Global Encoding

Select the encoding to use when other encoding options don’t apply.

For example, IntelliJ IDEA will use this encoding for files that are not part of any project or when you check out sources from a version control system.

Project Encoding

Select the encoding to use for files that are not listed in the table below.

Path

Specify the path to the files or directories for which you want to configure the encoding.

Encoding

Select the encoding to use for the specified files and directories.

If this selector is disabled, the file probably has a BOM or declares the encoding explicitly. In this case, you can’t configure the encoding to use for this file.

The encoding selected for a directory applies to all files and subdirectories within it.

Default encoding for properties files

Select the encoding for properties files in your project.

The Java 1.8 API is designed to use the ISO 8859-1 encoding for properties files. You can use escape sequences for characters that are not defined by this encoding. Alternatively, you can define the default encoding for properties files on the project level and use a different API that can read properties files in the encoding you have defined.

Transparent native-to-ascii conversion

Show national characters (those not defined in ISO 8859-1) in place of the corresponding escape sequences.

Compare the representation of national characters

By default, IntelliJ IDEA converts native characters to ASCII escape sequences with uppercase letters. To use lowercase letters, add the following platform property to the custom properties file and restart the IDE:

idea.native2ascii.lowercase=true

For more information, see Platform properties.

Create UTF-8 files

Select how IntelliJ IDEA should create UTF-8 files:

  • with BOM

  • without BOM

  • with BOM on Window and without BOM otherwise

By default, IntelliJ IDEA creates UTF-8 files without the BOM because some software is not compatible with the BOM, and it may be a problem when interpreting scripts. However, in some cases, you may want to have the BOM in your UTF-8 files.

Last modified: 27 December 2022

Кажется, это действительно бред, но я ничего не могу сделать со сломанной кодировкой в ​​консоли своего IntelliJ IDEA.

Что я сделал, чтобы преодолеть это:

  1. Установите -Dfile.encoding=UTF-8 и -Dfile.encoding=UTF-8 как в idea.exe.vmoptions , так и в idea64.exe.vmoptions (хотя я использую 64-битную версию).
  2. Добавлены -Dfile.encoding=UTF-8 и -Dfile.encoding=UTF-8 для запуска/отладки конфигурации моего приложения.
  3. Изменены настройки > Редактор > Кодировки файлов Кодировка IDE/Кодировка проекта/Кодировка по умолчанию для файлов свойств на UTF-8.

После того, как все это сделано, удачи по-прежнему нет, и символы в консоли отображаются неправильно. Я попытался отладить метод java.io.PrintStream#println(java.lang.String) и обнаружил, что System.out.textOut.out.se.cs равно windows-1251. Не знаю, откуда берется это значение.

Эта проблема беспокоила меня в течение долгого времени, и я не мог найти ничего в Интернете, что могло бы мне помочь.

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.

Status bar encoding

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

In the Settings/Preferences dialog ( Ctrl+Alt+S ), select Editor | File Encodings .

IntelliJ IDEA uses these settings to view and edit files for which it was not able to detect the encoding and also uses the specified encodings for new files.

Select the encoding to use when other encoding options don’t apply.

For example, IntelliJ IDEA will use this encoding for files that are not part of any project or when you check out sources from a version control system.

Select the encoding to use for files that are not listed in the table.

Specify the path to the files or directories for which you want to configure the encoding.

Select the encoding to use for the specified files and directories.

If this selector is disabled, the file probably has a BOM or declares the encoding explicitly. In this case, you can’t configure the encoding to use for this file.

The encoding selected for a directory applies to all files and subdirectories within it.

Default encoding for properties files

Select the encoding for properties files in your project.

The standard Java API is designed to use the ISO 8859-1 encoding for properties files. You can use escape sequences for characters that are not defined by this encoding. Alternatively, you can define the default encoding for properties files on the project level and use a different API that can read properties files in the encoding you have defined.

Transparent native-to-ascii conversion

Show national characters (those not defined in ISO 8859-1) in place of the corresponding escape sequences.

Create UTF-8 files

Select how IntelliJ IDEA should create UTF-8 files:

with BOM on Window and without BOM otherwise

By default, IntelliJ IDEA creates UTF-8 files without the BOM because some software is not compatible with the BOM, and it may be a problem when interpreting scripts. However, in some cases, you may want to have the BOM in your UTF-8 files.

To add or remove the BOM from all UTF-8 files in your project, right-click the name of your project in the Project tool window and select either Add BOM or Remove BOM .

Select console output encoding

By default, IntelliJ IDEA uses the system encoding to view console output.

In the Settings/Preferences dialog ( Ctrl+Alt+S ), select Editor | General | Console .

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 indexed maven repositories error
  • Integration error packages integration packages not found
  • Intelilite mrs 16 ошибки
  • Integration error customize integration customize not found
  • Integral nonlinearity error