- Published on
Windows 开发环境设置 UTF-8
- Authors
- Name
 
 
Encoding on Windows is painful.
System 
System Settings (win + i) -> language settings -> Administrative language settings -> Administrative -> Change system locale
勾选:Beta: Use Unicode UTF-8 for worldwide language support
Windows 11 默认启用
Cmd 
cmd
chcp 65001Windows 11 默认启用
PowerShell 
powershell
vim $PROFILE
# add this line to the top
$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8EncodingGit 
Less 
提供环境变量(参考):
LESSCHARDEF: UTF-8 LESSCHARSET: UTF-8
以管理员身份启动 PowerShell,然后执行:
powershell
[Environment]::SetEnvironmentVariable('LESSCHARSET', 'UTF-8', 'Machine')
[Environment]::SetEnvironmentVariable('LESSCHARDEF', 'UTF-8', 'Machine')Java 
提供环境变量:
JShell 等相关命令行工具 
JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
Maven 
MAVEN_OPTS: -Duser.language=cn -Dfile.encoding=UTF-8
Gradle 
GRADLE_OPTS: -Dfile.encoding=utf-8
或者设置 gradle.properties:
properties
org.gradle.jvmargs=-Dfile.encoding=UTF-8IDEA 
Settins (Ctrl + Alt + s) -> Editor -> File Encodings -> Project Encoding