teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

追記

2019/07/27 00:40

投稿

Zuishin
Zuishin

スコア28675

answer CHANGED
@@ -4,4 +4,13 @@
4
4
 
5
5
  https://docs.microsoft.com/ja-jp/dotnet/api/system.io.file.writealllines?view=netframework-4.8 を使ってください。
6
6
 
7
- BOM 無しの Encoding は https://docs.microsoft.com/ja-jp/dotnet/api/system.text.utf8encoding.-ctor?view=netframework-4.8#System_Text_UTF8Encoding__ctor_System_Boolean_ を false で作ってください。
7
+ BOM 無しの Encoding は https://docs.microsoft.com/ja-jp/dotnet/api/system.text.utf8encoding.-ctor?view=netframework-4.8#System_Text_UTF8Encoding__ctor_System_Boolean_ を false で作ってください。
8
+
9
+ # 追記
10
+
11
+ ```ps1
12
+ $encoding = New-Object System.Text.UTF8Encoding $false
13
+ [System.IO.File]::WriteAllLines($outfile, (go run "tree.go"), $encoding)
14
+ ```
15
+
16
+ なお $outfile をフルパスで指定しなければ思わぬところに保存されるかもしれません。そうでない場合は `Convert-Path` を使ってフルパスに直してください。