如何用UTF-8字符替换ANSI字符并以UTF-8格式保存文档? [英] How to replace ANSI characters with UTF-8 characters and save the document in UTF-8 format?

查看:126
本文介绍了如何用UTF-8字符替换ANSI字符并以UTF-8格式保存文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试运行此命令:

(Get-Content c:\example.srt).replace('æ', 'ć') | Set-Content c:\example.srt

但是它仅将字符æ替换为ANSI c.

But it only replaces the character æ with ANSI c.

我还希望能够同时替换多个字符.

I'd also like to be able to replace more than 1 character at the time.

推荐答案

您可以尝试一下.它将文件从 Windows-1252 转换为

You can give this a go. It converts a file from Windows-1252 to UTF-8.

$ansi = [System.Text.Encoding]::GetEncoding(1252)

Get-Content -Encoding $ansi "c:\example.srt" | Out-File -Encoding UTF-8 "c:\example.srt"

这篇关于如何用UTF-8字符替换ANSI字符并以UTF-8格式保存文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆