How to fix incorrect Cyrillic display in VS Code?
Problem: When running code in VS Code, Cyrillic text displays as hieroglyphs.
Current situation:
- UTF-8 beta testing in Windows is disabled
- When UTF-8 beta testing is enabled in VS Code, Cyrillic displays correctly
- However, enabling UTF-8 beta testing causes issues with another program (Access) - it stops launching
- In Access, Cyrillic only displays correctly when UTF-8 beta testing is disabled
Question: How can the Cyrillic display issue in VS Code be resolved without having to constantly enable/disable UTF-8 beta testing for each program?
The main issue with displaying Cyrillic text in VS Code on Windows occurs due to conflicts between VS Code’s encoding settings and Windows system settings. Several solutions are available that don’t require constantly enabling/disabling the UTF-8 beta test.
Table of Contents
- VS Code Settings for Correct Cyrillic Display
- Changing Encoding for Specific Files
- VS Code Terminal Settings
- Alternative Solution Methods
- Preventing Conflicts with Other Programs
VS Code Settings for Correct Cyrillic Display
The primary solution to the problem without enabling the UTF-8 beta test is to configure encoding parameters directly in VS Code. Add the following settings to your settings.json file:
{
"files.encoding": "utf8",
"files.autoGuessEncoding": true,
"terminal.integrated.defaultProfile.windows": "Command Prompt",
"terminal.integrated.profiles.windows": {
"Command Prompt": {
"path": "cmd.exe",
"args": ["/K", "chcp 65001"]
}
}
}
Explanation:
files.encoding: "utf8"sets UTF-8 as the default encoding for all filesfiles.autoGuessEncoding: trueenables automatic encoding detection when opening files- The terminal settings ensure that the command prompt will use UTF-8 (via
chcp 65001)
Changing Encoding for Specific Files
For individual files that already contain Cyrillic text, you can change their encoding without modifying global settings:
- At the bottom of the VS Code window, you’ll see an encoding label (usually “UTF-8”)
- Click on this label
- In the menu that appears, select “Save with encoding”
- Choose the appropriate encoding:
- UTF-8 - for most cases
- UTF-8 with BOM - if the file was created with a byte order mark
- Windows 1251 - if the file was originally in this encoding
Important: When saving a file with Cyrillic text in UTF-8 encoding without BOM, ensure that all UTF-8 supporting editors can open it correctly.
VS Code Terminal Settings
Issues with displaying Cyrillic text often occur specifically in console output. To resolve this issue:
- Open VS Code settings (
Ctrl+,) - Add the setting:json
"terminal.integrated.defaultProfile.windows": "Command Prompt" - Or create a terminal profile with explicit encoding setup:
"terminal.integrated.profiles.windows": {
"UTF-8 Command Prompt": {
"path": "cmd.exe",
"args": ["/K", "chcp 65001 && title UTF-8 Terminal"]
}
}
Alternative Solution Methods
Using Third-Party Extensions
Install the “Code Runner” extension from Marketplace. It allows you to run code in the terminal with proper encoding:
- Install the “Code Runner” extension by Jun Han
- In settings, add:json
"code-runner.executorMap": { "javascript": "cd $dir && node $fileName", "python": "cd $dir && python $fileName", // other languages... }
Changing Windows System Settings
If the problem persists, you can change the system locale without enabling the UTF-8 beta test:
- Press
Win + R, typeintl.cpl - Go to the “Administration” tab
- Click “Change system locale”
- In the “Non-Unicode programs language” section, uncheck “Beta: Use Unicode UTF-8 for worldwide language support”
- Select an appropriate language (e.g., Russian)
- Restart your computer
Preventing Conflicts with Other Programs
To avoid conflicts with MS Access and other programs that don’t work with the UTF-8 beta test, use the following strategy:
-
Configure VS Code separately for working with Cyrillic text through
files.encoding -
Use different Windows profiles for different tasks:
- Profile for development with UTF-8 beta test enabled
- Profile for working with Access with UTF-8 beta test disabled
-
Create a batch script for quick mode switching:
@echo off
echo Enabling UTF-8 for VS Code...
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage" /v "ACP" /t REG_SZ /d "65001" /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage" /v "OEMCP" /t REG_SZ /d "65001" /f
echo UTF-8 enabled. Please restart VS Code.
pause
Save this script as enable_utf8.bat and run it before working with VS Code.
Sources
- Character encoding - All Russian letters change to “???” in Visual Studio Code - Stack Overflow
- Change the encoding of a file in Visual Studio Code - Stack Overflow
- VS Code doesn’t correctly display Russian letters · Issue #41401 · microsoft/vscode
- Visual studio code Change encoding for single files and Permanently - w3schools
- How to change File Encoding in VS Code - DeveloperF1.com
Conclusion
To solve the problem of displaying Cyrillic text in VS Code without enabling the UTF-8 beta test, we recommend:
- Primary solution: Configure
files.encoding: "utf8"andfiles.autoGuessEncoding: truein VS Code settings - Additional measures: Change encoding for specific files through the VS Code interface
- For the terminal: Set UTF-8 encoding via
chcp 65001in terminal settings - Alternative: Use the Code Runner extension or change Windows system settings
- For preventing conflicts: Create separate Windows profiles or use scripts for mode switching
These methods will allow correct display of Cyrillic text in VS Code without affecting other programs such as MS Access.