Powershell 2.0 generates nulls between characters

前端 未结 2 768
天涯浪人
天涯浪人 2021-01-08 00:10

With powershell 2.0:

write-output \"abcd\" >> mytext.txt  

returns:

a nul b nul c nul d nul

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-08 00:37

    Powershell works in 16 bit unicode by default, and however you're reading the file is likely in an 8 bit format. You could interpret the sql in an application that can read UTF16, or, because >> is syntactic sugar for the out-file cmdlet, you can do the following instead:

    write-output "abcd" | out-file -path mytext.txt -Encoding "UTF8" -Append
    

提交回复
热议问题