将RTF特殊字符输出为Unicode

3

我在Google和Stackoverflow上搜索了很久,但是没有找到我需要的答案,不过我的问题似乎很简单。无论如何;

使用C#将RTF特殊字符的字符串(例如"\ 'd3' d6"(在此情况下为俄语))转换为Unicode字符或字符串的方法是什么?

2个回答

6

0

您可以转换这些字符:

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;
  }
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接