There is a text

% E4% E8% EC% EA% E0% E0% E0% E01998

Artemy decoder says that this is URL-encoded → CP1251 and that the text is Dimkaaaa1998

I try to do it in Sharpe, but for some reason the result is not the one that should turn out. The output is some kind of cotovasia

var str = Uri.UnescapeDataString("%FB%E2%F4%FB%E2%F4%FB%E2%F4"); Encoding srcEncodingFormat = Encoding.UTF8; Encoding dstEncodingFormat = Encoding.GetEncoding("windows-1251"); byte[] originalByteString = srcEncodingFormat.GetBytes(str); byte[] convertedByteString = Encoding.Convert(srcEncodingFormat, dstEncodingFormat, originalByteString); string finalString = dstEncodingFormat.GetString(convertedByteString); 
  • Strange, the decoder Lebedeva returned to me the text of the ьарьарьар and the encoding URL-encoded → KOI8-R + CP1251 → KOI8-R - sp7
  • codenet.ru/services/urlencode-urldecode - it looks more reliable here, paste in the box for windows-1251 - Monk
  • Sorry, the wrong line gave. Here is the line% E4% E8% EC% EA% E0% E0% E0% E01998 - Radzhab

1 answer 1

It should be like this:

 var strEnc = "%E4%E8%EC%EA%E0%E0%E0%E01998"; var win1251 = Encoding.GetEncoding("windows-1251"); var strDec = HttpUtility.UrlDecode(strEnc, win1251); 
  • And how did you guess what should be decoded there)? - Rajab
  • @Radzhab from the description of the question. The source string is the url-encoded bytes cp1251, it is logical to get unicode using this encoding and decode. Or the question is not about that? - Petr Abdulin