0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Windows] [VSC] [C/C++] ターミナルで実行した際の文字化けを直す

Last updated at Posted at 2025-11-27

C言語、C++をVSCでしていくにあたって、ターミナルで日本語の文字化けが起こったので、解決した方法について伝えていく。

まず初めに
VSCのターミナルで、PowerShellかコマンドプロンプトのどちらが使われているか確認。

確認方法
実行ファイルの起動を、「実行ファイル」の入力だけで行っているならコマンドプロンプト、「./実行ファイル」の入力で行っているならPowerShellである。

コマンドプロンプトの場合
ターミナルに以下を入力。

chcp 65001

PowerShellの場合
ターミナルに以下を入力。

chcp 65001 > $null
[Console]::InputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$OutputEncoding = [System.Text.Encoding]::UTF8
$PSDefaultParameterValues['*:Encoding'] = 'utf8'

以上である。






<補足>(Copilotによる)
文字コードは、「画面表示」「外部コマンド連携」「ファイル入出力」それぞれで設定される。
そしてコードを変化させる時は、「その場だけ」「起動時自動」「永続」の三種類。

上に示したコマンドプロンプトのコードは、「画面表示」、「その場だけ」。
PowerShellのコードは、「画面表示」「外部コマンド連携」「ファイル入出力」、「その場だけ」。

*ご利用はご自身の責任でお願いします。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?