在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。