4
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Visual Studio Code を使って、PowerShell を書きはじめるときにしたこと

4
Last updated at Posted at 2017-04-18

インストール

  • PowerShell の拡張機能をインストール

書いてみる

  1. メニューから新規ファイルを作成

  2. ファイル名 helloworld.ps1 として保存
    ステータスバーが下記のようになる
    vscode.PNG

  3. 下記のコードを記述

Write-Host 'Hello world'

入力補完も効く
vscodeac.PNG
4. Ctrl + Shift + D でデバッグウィンドウを起動
vscodedebug.PNG
虫のアイコンからも起動可能
5. 上部の▶クリックでデバッグが開始される
6. 隣のアイコンクリックでコンソールが開く
vscoderun.PNG

日本語を表示してみる

vscodebake.PNG
文字化け。。

chcp コマンドでコンソールのエンコードを確認
vscodechcp2.PNG

932です。

ファイルのエンコードが UTF-8 なので、一旦コンソールを UTF-8 にしてみる
vscode65001.PNG

なんでやねん

わからん。。

こちらのページが自分と同じ状況だったので、
参考にさせていただく。
http://thinkami.hatenablog.com/entry/2016/07/08/065709

UTF-8 BOM の設定をする
「エンコード付きで保存」から「UTF-8 with BOM」を選択する

vscode65001OK.PNG

vscode932OK.PNG
両方とも表示されている

Powershell は UTF-8 の BOM 付きじゃないと文字化けするみたい
参考
http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q10137216220

4
10
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
4
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?