powershell - 如何在 Powershell 中管理 Unicode 字符
问题描述
我创建了一个执行外部命令的 powershell 脚本。
$filenames = command.exe $remoteFolder
此命令返回文件名列表,但在 Unicode 中,文件名随后存储在输出 CSV 文件中
"$remoteFolder;$filename" >> $exportFile
不幸的是,输出文件没有正确显示重音字母
fileà.txt
让重音字母显示正确的最佳方法是什么?
谢谢。
解决方案
>>
在向其附加 utf16/unicode 字符之前不检查输出文件的编码,因此它可能会混合不同的编码。我会改为通过管道添加内容。该文件首先必须是 utf8 或 utf16。输出 unicode 字符的外部命令也可能存在问题。了解 unicode 字符和外部命令是什么会很有帮助。
"$remoteFolder;$filename" | add-content $exportFile
推荐阅读
- rest - MS Graph REST API 结账用户
- swift - Swift 中 String 的 4 位哈希
- pycharm - runnung pycharm中的Java虚拟机错误
- c# - 如何做id的内存管理
无效* 到 IntPtr - java - java.lang.ClassCastException:[Ljava.lang.Object;不能转换为 [Ljava.lang.Class;
- visual-studio - 签出 Visual Studio TFS 中的任何文件后,我正在注销
- c# - 为编译时设计基于模型的系统
- vue.js - 没有 vue-cli 的 vue 中 proxy.conf.json 的替代方案?
- javascript - 如何更改消息“您所做的更改可能无法保存。” 对于window.onbeforeunload?
- conditional-statements - Autosys 作业调度 - 具有月和日条件