3
我一直在看ocn谷歌和Stackoverflow,但还没有找到我需要的东西,但我的问题似乎很简单。无论如何;输出RTF特殊字符为Unicode
什么是转换一串RTF特殊字符,如“\'d3 \'d6”(在这种情况下,俄语)到Unicode字符或字符串使用C#?
我一直在看ocn谷歌和Stackoverflow,但还没有找到我需要的东西,但我的问题似乎很简单。无论如何;输出RTF特殊字符为Unicode
什么是转换一串RTF特殊字符,如“\'d3 \'d6”(在这种情况下,俄语)到Unicode字符或字符串使用C#?
以下任一应该有所帮助:
\'d3\'d6
是十六进制值[s],基于指定的字符集。所以你可以编写自己的处理函数,比如分割字符串\'
,将hex转换为char,重新加入它,转换为unicode。您可以将这些字符:
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;
}
}