我有一个文本文件input.xlf
<trans-unit id="loco:5e7257a0c38e0f5b456bae94">
<source>Login</source>
<target>登入</target>
<note>Login Header</note>
</trans-unit>
基本上我需要用 <
代替 <
,用 >
代替 >
,因此我运行以下脚本:
runner.bat
powershell -Command "(gc input.xlf) -replace '<', '<' | Out-File -encoding ASCII output.xlf";
powershell -Command "(gc output.xlf) -replace '>', '>' | Out-File -encoding ASCII output.xlf";
上述代码在我发现以下输出后便不再起作用。
<trans-unit id="loco:5e7257a0c38e0f5b456bae94">
<source>Login</source>
<target>??????</target>
<note>Login Header</note>
</trans-unit>
我尝试移除编码,但现在我得到了:
<trans-unit id="loco:5e7257a0c38e0f5b456bae94">
<source>Login</source>
<target>登入</target>
<note>Login Header</note>
</trans-unit>
以下是我期望的输出结果
<trans-unit id="loco:5e7257a0c38e0f5b456bae94">
<source>Login</source>
<target>登入</target>
<note>Login Header</note>
</trans-unit>
ASCII
编码,它不支持 Unicode 字符。 - Hazel へいぜる登录
,与没有编码时的结果相同。 - Owen Kelvin