开发者

How to encode U+FFFD in order to do a replace?

开发者 https://www.devze.com 2023-02-05 22:17 出处:网络
In a text file I obtain from a 开发者_如何学JAVAsource I do not control, and which text content changes periodically and I have to compensate by re-downloading and processing, the char U+FFFD occurs f

In a text file I obtain from a 开发者_如何学JAVAsource I do not control, and which text content changes periodically and I have to compensate by re-downloading and processing, the char U+FFFD occurs frequently (but not always) when what is meant is the single quote or ' character.

How can I encode a replace operation so as to replace the U+FFFD with an actual single-quote in C#. I envision something like:

string s = s.Replace("U+FFFD", "'");

Clearly I should use the overload that deals with char, but I am not sure how to encode the U+FFFD, or for that matter, the single quote!


string s = s.Replace('\uFFFD','\'');
0

精彩评论

暂无评论...
验证码 换一张
取 消