Read UTF-8 files correctly with PowerShell

后端 未结 3 705
慢半拍i
慢半拍i 2020-12-29 09:58

Following situation:

  • A PowerShell script creates a file with UTF-8 encoding
  • The user may or may not edit the file, possibly losing the BOM, but should
3条回答
  •  滥情空心
    2020-12-29 10:14

    If the file is supposed to be UTF8 why don't you try to read it decoding UTF8 :

    Get-Content -Path test.txt -Encoding UTF8
    

提交回复
热议问题