用特殊字符将字符串文本替换为文件 [英] Replace string text into file with special characters

查看:72
本文介绍了用特殊字符将字符串文本替换为文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我正在替换文件中的一串字符,但我对特殊字符有疑问。

我用这用于将文本替换为文件

Hello,

I am replacing a string of characters in a file but i have a problem with special characters.
I use this for replace text into file

My.Computer.FileSystem.WriteAllText(path2, My.Computer.FileSystem.ReadAllText(path2).Replace(renfile7, renfile4), False, System.Text.Encoding.GetEncoding(1252))





它有效。



原始文件读取Notepad ++ ANSI编码





and it works.

Original file read with Notepad ++ ANSI encoding

ÐÏࡱá          





WriteAllText后替换字符????





After WriteAllText the characters replaced ????

????         





我想保留特殊字符,这是编码问题吗?



I would want to leave the special characters intact, it is a problem of encoding?

推荐答案

你应该读到这个:每个程序员绝对需要了解编码和字符集以处理文本 [ ^ ]



1252编码是有限的,因此没有所需的所有字符。



祝你好运!
You should read this:What Every Programmer Absolutely, Positively Needs to Know About Encodings and Character Sets to Work With Text[^]

1252 encoding is limited and therefor doesn't have all the characters needed.

Good luck!


这篇关于用特殊字符将字符串文本替换为文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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