我正在尝试输出一堆数据,并使用一些德国的Umlauts:ä,ö,ü,.我在Export-Csv的末尾添加了-Encoding UTF8,但它并不能真正工作。我的代码:
For ($i = 0; $i -lt $accFileCont.Length; $i++) {
$accFileCont[$i] | Export-Csv $outAccFile -NoTypeInformation -Encoding UTF8
}我期待着ä,ö,ü...不是“?”,而是...这里出了什么问题?它不输出Umlauts。提前感谢:)
发布于 2021-02-10 19:46:38
对我来说,实际上是"-Encoding utf8BOM“完成了这项工作
环境: Windows 10 20H2德语版、德国Excel版、PowerShell 7
如果我没有使用utf8BOM,我的德语Excel不能正确显示“变音”。
There is a whole discussion about UTF8 with or without BOM
实际上"Marius“wrote the following comment:”它可能不被推荐,但它在尝试输出“didønot”时对我的powershell脚本产生了奇迹。“
"C:\sources\new_18.json“的格式是UTF8(它是一个简单的JSON文件)
"-Delimiter ";"“用于德国Excel
$TestVariable = (Get-Content -raw -Encoding UTF8 "C:\sources\new_18.json") | ConvertFrom-Json
$TestVariable.value | Export-Csv "C:\sources\PSOutput\Output_$((Get-Date).ToString('MM-dd-yyyy_hh-mm-ss')).csv" -NoTypeInformation -Delimiter ";" -Encoding utf8BOM对于PowerShell 5:将"-Encoding utf8BOM“更改为"-Encoding utf8”(在Powershell 5中,"Export-Csv -Encoding utf8“saves in utf8BOM")
https://stackoverflow.com/questions/55853647
复制相似问题