小编Gus*_*der的帖子

PowerShellscript,错误的文件编码对话

我有一个用于文件字符编码对话的PowerShell脚本.

Get-ChildItem -Path D:/test/data -Recurse -Include *.txt |
ForEach-Object {
  $inFileName = $_.DirectoryName + '\' + $_.name
  $outFileName = $inFileName + "_utf_8.txt"
  Write-Host "windows-1251 to utf-8: " $inFileName -> $outFileName  
  E:\bin\iconv\iconv.exe -f cp1251 -t utf-8 $inFileName > $outFileName
}
Run Code Online (Sandbox Code Playgroud)

但它不是utf-8,而是将文件字符编码转换为utf-16.当我从命令行调用iconv实用程序时,它工作正常.

我错了什么?

powershell character-encoding iconv

4
推荐指数
1
解决办法
4064
查看次数

标签 统计

character-encoding ×1

iconv ×1

powershell ×1