这个问题不应该在这里悬而未决困境
Q
悬而未决困境
-1
A
回答
1
默认编码>
Redirection以及为Out-File是Unicode:
的
Out-File
cmdlet可以将输出发送到一个文件中。当你需要使用它的 参数您可以使用此cmdlet 而不是重定向运算符(>
)。-Encoding
指定文件中使用的字符编码的类型。有效 值是 “统一”, “UTF7”, “UTF8”, “UTF32”, “ASCII”, “BigEndianUnicode”, “默认” 和 “OEM”。
“统一”是默认。“默认”使用系统当前ANSI代码页的编码。
“OEM”使用操作系统的当前 原始设备制造商代码页标识符。
示例脚本:
''
'$outputencoding>$env:TEMP\40763209.txt'
$outputencoding>$env:TEMP\40763209.txt
(Get-Content -Path $env:TEMP\40763209.txt -Encoding Byte -TotalCount 16 |
ForEach-Object {"{0:x2}" -f $_}) -join ' '
''
'$outputencoding|out-file $env:TEMP\40763209a.txt -Encoding utf8'
$outputencoding|out-file $env:TEMP\40763209a.txt -Encoding utf8
(Get-Content -Path $env:TEMP\40763209a.txt -Encoding Byte -TotalCount 16 |
ForEach-Object {"{0:x2}" -f $_}) -join ' '
输出:注意这两个文件Byte Order Mark签名:
PS D:\PShell> D:\PShell\SO\40763209.ps1
$outputencoding>$env:TEMP\40763209.txt
ff fe 0d 00 0a 00 0d 00 0a 00 49 00 73 00 53 00
$outputencoding|out-file $env:TEMP\40763209a.txt -Encoding utf8
ef bb bf 0d 0a 0d 0a 49 73 53 69 6e 67 6c 65 42
+0
我的问题正是在这一步之后:我能够通过简单地打开带有重定向输出的文本文件并在记事本中单击“另存为...”来识别编码。问题是,将文件内容转换为** any **其他编码会导致相同的情况:每个字符之间有空格,在某些情况下甚至有两个空格。 避免材料清单是我已经尝试通过阅读许多类似于我的网上类似问题。 – REMOVED
相关问题
- 1. WaitOnAddress悬而未决
- 2. 悬而未决进口gcs_oauth2_boto_plugin
- 3. 悬而未决列入WProgram.h
- 4. 悬而未决imprort:x范围
- 5. j_security_check困境 - 解决方法
- 6. 悬而未决METAS在阿格达
- 7. JavaScript的:变量名悬而未决
- 8. SBT-蚀悬而未决例外
- 9. 异步操作仍悬而未决
- 10. 悬而未决参考Django的
- 11. 悬而未决参考get_func()在pycharm
- 12. 悬而未决R.id在android系统
- 13. “悬而未决导入”与模块
- 14. 如何看待悬而未决的git?
- 15. 悬而未决参考类,方法
- 16. SBT悬而未决扶养到的MaxMind
- 17. 解决XML文档注释困境
- 18. 如何解决悬而未决的功能检查在WebStorm 10
- 19. 而异步操作仍然悬而未决
- 20. TreeTableView困境
- 21. WPF SolidColorBrush困境
- 22. Codeigniter URL困境
- 23. toolbaritem的困境
- 24. java.io困境
- 25. JPA @OneToMany困境
- 26. WinAPI ZOrder困境
- 27. 笨xss_clean困境
- 28. sendmail.php困境。
- 29. 递归困境
- 30. 困境与
'[控制台] :: OutputEncoding = [Text.Encoding] :: UTF8'或'开始处理-RedirectStandardOutput' – PetSerAl
那么你应该张贴一些代码,或者更好[MCVE。有很多地方可能会出错,但没有任何人只能猜测的代码。 – PetSerAl
请编辑您的问题,而不是在评论中张贴代码片段。按照@ PetSerAl的评论,发布[mcve]。 – JosefZ