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

眉间皱痕 提交于 2019-12-12 17:55:20

问题


In a text file I obtain from a source 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!


回答1:


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


来源:https://stackoverflow.com/questions/4766778/how-to-encode-ufffd-in-order-to-do-a-replace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!