将RTF特殊字符输出为Unicode

我一直在寻找谷歌和Stackoverflow,但没有找到我需要的东西,但我的问题似乎很简单。 无论如何;

将一串RTF特殊字符(例如“\’d3 \’d6”(在本例中为俄语)转换为使用C#的unicode字符或字符串的方法是什么?

以下任何一项应该有所帮助:

  • RTF格式(RTF)规范,版本1.6,特殊字符 。 根据这个, \'d3\'d6hex值[s],基于指定的字符集 。 所以你可以编写自己的处理函数,比如将字符串拆分为\' ,将hex转换为char,重新加入,转换为unicode。
  • 如何:将RTF转换为纯文本
  • NRTFTree – C#中RTF处理的类库
  • 有关SO标记的rtf和c#的问题
  • 谷歌搜索“rtf c#”

你可以转换这些字符:

 int findUTF = -1; bool continueUTFSearch = true; do { findUTF = HTMLText.IndexOf(@"\'", findUTF + 1); if (findUTF != -1) { string replacedString = HTMLText.Substring(findUTF, 4); string esacpeddString = replacedString.Substring(2); int esacpeddCharValue = Convert.ToInt16(esacpeddString, 16); char esacpeddChar = Convert.ToChar(esacpeddCharValue); esacpeddString = esacpeddChar.ToString(); HTMLText = HTMLText.Replace(replacedString, esacpeddString); findUTF = -1; } else { continueUTFSearch = false; } }