-1

I can`t find the way out...

Im working with some website throughHTTPRequests`. in the page content, I receive a symbols like this:

u0432\u0438\u043a\u0438    

what is it? how can I decode it, using C#?

Suhaib Janjua
  • 3,538
  • 16
  • 59
  • 73
user1935987
  • 3,136
  • 9
  • 56
  • 108

1 Answers1

1
var src= "\u0438"; 
Console.WriteLine(Encoding.GetEncoding(65001).GetString(Encoding.GetEncoding(65001).GetBytes(src)));

Assuming you're using UTF-8. If the values don't check, please view this link. https://msdn.microsoft.com/en-us/library/system.text.encoding.getencodings%28v=vs.110%29.aspx

Artur Peniche
  • 481
  • 6
  • 27
  • thanks! that works. i was so confused, what kind of encoding it would be. Thought some cryptography – user1935987 Apr 22 '15 at 08:48
  • when i put the string `string token = "\u041e\u0448\u0438\u0431";` `string decoded = (Encoding.GetEncoding(65001).GetString(Encoding.GetEncoding(65001).GetBytes(token)));` inside of the code - everything works ok. but when i`m reseiving the totally same string from the website - it doesn`t works, i just getting the same string back. why is it can happened? i used an encoding determination methods from here http://stackoverflow.com/questions/1025332/determine-a-strings-encoding-in-c-sharp and getting the result what in the httpresponse i`m getting a "unicode" string. – user1935987 Apr 22 '15 at 10:54
  • that's weird, maybe you're not parsing the string in a proper way?by the way are you supposed to receive that kind of symbols? In the dark part of the internet that may be used as a sort of attack – Artur Peniche Apr 22 '15 at 13:04
  • already found a solution - just parse a JSON response by the newton.json library. it fixes this prob with this symbols. sort of attack, receiving a response from server? how? – user1935987 Apr 23 '15 at 17:57
  • i'm glad you found a way to fix this :) if you're receiving this symbols from a trustful source i guess there's no problem, i thought in the beginning you weren't aware of the source, so it could be for example an homograph attack – Artur Peniche Apr 24 '15 at 08:35