在Debian系统中解决PhpStorm乱码问题,可按以下步骤操作:
设置文件编码
配置系统环境
locale,确认输出中包含 zh_CN.UTF-8 或 en_US.UTF-8。/etc/locale.gen,取消对应编码的注释,运行 sudo locale-gen 生成配置。~/.bashrc 中添加:export LANG=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8
执行 source ~/.bashrc 生效。修改PhpStorm配置文件
bin 文件夹中找到 phpstorm64.vmoptions(64位系统),添加以下内容:-Dfile.encoding=UTF-8
安装中文字体
/usr/share/fonts/truetype/,执行:sudo chmod 777 /usr/share/fonts/truetype/*
sudo fc-cache -fv
检查PHP代码与数据库
header('Content-Type: text/html; charset=utf-8');
$mysqli->set_charset("utf8mb4"))。完成以上步骤后,若问题仍未解决,可尝试重启系统或重新安装PhpStorm。