LoginSignup
1

More than 5 years have passed since last update.

Azure WebJobs で PowerShell から日本語での標準出力を文字化けさせない関数

Posted at
function Write-OutputByNativeEnc($message) {

    # UTF-8 としてバイト配列化し、コンソールのネイティブなエンコードに変換
    [Console]::OutputEncoding.GetString([Text.Encoding]::UTF8.GetBytes($message))

}

※ ps1 ファイルが UTF-8 の場合

C#アプリの場合は Console.OutputEncoding = System.Text.Encoding.UTF8; をおまじないすると、以後は Console.Write{Line}(); で文字化けせず。

*.bat, *.cmd の echo と、 *.js(node) の console.log(); は、そもそも文字化けせず。

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
What you can do with signing up
1