今天在用 Windows 弄 Electron的时候,在控制台中编译,发现中文在控制台中显示乱码
WebStorm 控制台出现乱码通常是由于编码设置不匹配造成的。
步骤一:修改 WebStorm 全局编码设置
1. 打开 WebStorm
2. 进入 File > Settings (Windows/Linux) 或 WebStorm > Preferences (macOS)
3. 导航到 Editor > File Encodings
4. 确保以下选项设置为 UTF-8:
5. Global Encoding: UTF-8
6. Project Encoding: UTF-8
7. Default encoding for properties files: UTF-8
8. 勾选 "Transparent native-to-ascii conversion" 选项
9. 点击 "OK" 保存设置
步骤二:修改 WebStorm 启动配置
1. 找到 WebStorm 的启动脚本(通常在安装目录的 bin 文件夹中)
2. 编辑 webstorm.vmoptions 或 webstorm64.vmoptions 文件
3. 添加以下行: -Dfile.encoding=UTF-8
步骤三:设置系统注册表 (Windows)
1. win + r,打开运行窗口,输入 "regedit" 打开注册表
2. 修改注册表: 路径: 计算机\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor --> 添加一个字符串值 (名称为:autorun 数据为:chcp 65001)
3. 重启 WebStorm 看效果
到这里就修改完毕啦
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以【一键三连】。您的鼓励是博主的最大动力!