前提
RustでVisual Studio Codeを用いてデバッグすると日本語部分が文字化けしてしまいます。
OSはWindows11です。
実現したいこと
cargo runでは文字化けせずに「Hello, 世界!」と表示されます。
しかし、デバッガーで動かすと「Hello, 荳也阜・・」と表示されてしまいます。
デバッグ中も日本語部分を文字化けせずにターミナル表示させる方法は無いでしょうか?
デバッガーはLLDBを用いていますが他のものでも構いません。
該当のソースコード
main.rs
Rust
1fn main() { 2 println!("Hello, 世界!"); 3} 4
launch.jsonは初期値から変更していません。
json
1{ 2 // IntelliSense を使用して利用可能な属性を学べます。 3 // 既存の属性の説明をホバーして表示します。 4 // 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387 5 "version": "0.2.0", 6 "configurations": [ 7 { 8 "type": "lldb", 9 "request": "launch", 10 "name": "Debug executable 'hello'", 11 "cargo": { 12 "args": [ 13 "build", 14 "--bin=hello", 15 "--package=hello" 16 ], 17 "filter": { 18 "name": "hello", 19 "kind": "bin" 20 } 21 }, 22 "args": [], 23 "cwd": "${workspaceFolder}" 24 }, 25 { 26 "type": "lldb", 27 "request": "launch", 28 "name": "Debug unit tests in executable 'hello'", 29 "cargo": { 30 "args": [ 31 "test", 32 "--no-run", 33 "--bin=hello", 34 "--package=hello" 35 ], 36 "filter": { 37 "name": "hello", 38 "kind": "bin" 39 } 40 }, 41 "args": [], 42 "cwd": "${workspaceFolder}" 43 } 44 ] 45} 46
Cargo.tomlも初期値から変更していません。
toml
1[package] 2name = "hello" 3version = "0.1.0" 4edition = "2021" 5 6# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 8[dependencies]
追記(2023/01/12 15:30)
cargo runはVisual Studio Code のターミナルで実行しています。(画像参照)
また、chcpは932でした。chcp 65001にしても結果は同じでした。
デバッグを最後まで実行してもそのまま終了します。
また、デバッグ後、再度chcpを行うと、65001に変わっていました。(画像参照)
下記参考サイトも同様の現象を確認しているようで、私だけではなく皆発生するものだと考えています。
参考サイト
Windows10で動くVSCodeにRustの開発環境を作る
追記(2023/01/12 20:30)
VSCodeの設定情報です。
settings.json
json
1{ 2 "workbench.colorTheme": "Default Light+", 3 "git.autofetch": true, 4 "git.confirmSync": false, 5 "editor.accessibilitySupport": "off", 6 "editor.formatOnSave": true, 7 "editor.formatOnPaste": true, 8 "editor.formatOnType": true, 9 "C_Cpp.clang_format_style": "{BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 120}", 10 "[jsonc]": { 11 "editor.defaultFormatter": "esbenp.prettier-vscode" 12 }, 13 "terminal.integrated.defaultProfile.windows": "PowerShell", 14 "terminal.integrated.profiles.windows": { 15 "PowerShell": { 16 "source": "PowerShell", 17 "icon": "terminal-powershell", 18 "path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe" 19 } 20 } 21}

回答1件
あなたの回答
tips
プレビュー