Windows下 phpstorm terminal 中文亂碼解決辦法


解決辦法有多個,比如使用wsl,git的bash,而我要介紹的是使用原始的cmd解決utf-8編碼的問題,一般情況下我們在terminal 下執行php文件,如果里面有中文就會顯示亂碼,像下面這樣

Options:
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  auto_off                         姣忓垎閽熸嫻嬩竴嬈″渾緇囨満涓嬫満鏁版嵁
  automatic_deduction              姣忓ぉ8:50媯€嫻嬩竴嬈℃墍鏈夊叕鍙哥殑濂楅璧勮垂鎯呭喌騫舵墸璐

這是因為cmd默認使用的編碼是gbk(代碼936)

F:\>chcp
活動代碼頁: 936

解決思路就是把這里的編碼改為utf-8(65001)即可,之后在運行腳本就是正常的顯示了

F:\>chcp 65001
Active code page: 65001
...
Options:
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  auto_off                         每分鍾檢測一次***
  automatic_deduction              每天8:50檢測一次***

那么在terminal如何處理呢?
打開 File->Settings->Tools->Terminal,將Application settings下的Shell path設為 cmd.exe /k chcp 65001 & cls
以后就不用管文字編碼的問題,愉快地coding吧


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM