How to decode Feedburner result containing \x3c and so on

后端 未结 3 900
既然无缘
既然无缘 2021-01-16 17:50

Feed burner changed their blog service return results that it returns blocks of javascript similar to:

document.write(\"\\x3cdiv class\\x3d\\x22feed

相关标签:
3条回答
  • 2021-01-16 18:09

    That is a PHP Twig encoding:

    http://www.twig-project.org/

    Since you are using C# you will most likely have to create a dictionary to translate the symbols and then use a series of .Replace() string methods to convert those back to HTML characters.

    Alternatively you can save that data to a file, run a Perl script to decode the text and then read from the file in C#, but that might be more costly.

    0 讨论(0)
  • 2021-01-16 18:10

    In dotnet core you can use Uri.UnescapeDataString(originalString.Replace("\x","%")) to convert it by making it into a Url encoded string first.

    0 讨论(0)
  • 2021-01-16 18:16

    Those look like ASCII values, encoded in hex. You could traverse the string, and whenever you find a \x followed by two hexadecimal digits (0-9,a-f), replace it with the corresponding ASCII character. If the string is long, it would be faster to save the result incrementally to a StringBuilder instead of using String.Replace().

    I don't know the encoding specification, but there might be more rules to follow (for example, if \\ is an escape character for a literal \).

    0 讨论(0)
提交回复
热议问题