5
5

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.

PowerShell で svn log --xml の出力が文字化けする

Posted at

環境

環境は以下の通り。

  • Windows 7 SP1
  • PowerShell 2.0
  • Subversion 1.9.2 (TortoiseSVN 同梱のやつ)

問題

以下のように実行して文字化けする。

.\test.ps1
$log = & svn @('log', '-r', 'HEAD', '--xml', 'http://...')
$log
C:\>powershell -file .\test.ps1
...
<msg>文字化けする</msg>
...

対策

ググって以下の URL 先などを参考に

"クラシック コマンドと PowerShell の間のエンコード設定 - is BUG Ready ?"
http://d.hatena.ne.jp/ladybug/touch/20111203

以下のように修正して対策。

.\test.ps1
[System.Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$log = & svn @('log', '-r', 'HEAD', '--xml', 'http://...')
[System.Console]::OutputEncoding = [System.Text.Encoding]::Default
$log
5
5
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
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?