user1795928
user1795928

Reputation: 19

auto convert ascii values to acutal char

I have a huge string and few lines of it are given bellow:

\x5b\x5b\x5b\x220B_to5Zwh_yJXV2FKdHV2N1lndk0\x22,\x5b\x220APto5Zwh_yJXUk9PVA\x22\x5d\n,\x22OfferArcade\x22,\x22application/vnd.google-apps.folder\x22,0,0,0,0,1,1420447667416,1420447667294,1420447667294,1502262110474,null,\x5b\x5b1,\x2204490703266643460813\x22,\x22Priyam Paul\x22,null,\x22//lh4.googleusercontent.com/-FE82xOkpzWw/AAAAAAAAAAI/AAAAAAAAAd8/KPtKNTPPaNE/photo.jpg\x22

I am looking for a solution where it can automatically detect the ascii and convert it into the original char.

For example ascii \x5b is actually a [

So I need a solution which will automatically detect all the ascii's and convert those into the original char.

Upvotes: 0

Views: 166

Answers (1)

Jakub Dąbek
Jakub Dąbek

Reputation: 1044

You could use Regex.Unescape

//using System.Text.RegularExpressions;
string text = "\x5b\x5b\x5b\x220B_to5Zwh_yJXV2FKdHV2N1lndk0\x22"; //and so on
string decoded = Regex.Unescape(text);
Console.WriteLine(decoded);

Output:

[[["0B_to5Zwh_yJXV2FKdHV2N1lndk0"

Upvotes: 5

Related Questions