0

I tried to send a Chinese character through querystring and I get %E4%B8%AD.

I need it to be in decimal equivalent which is 20013.

How do I convert this set of hex numbers to dec ?

Josh Crozier
  • 202,159
  • 50
  • 343
  • 273

1 Answers1

0

20013 is the Unicode character for that Chinese character. The E4B8AD is the UTF8 encoding of that Unicode character. When sending things over between client and server, 2 things are specified so they can encode/decode properly and display the text. The 2 things are "Character Set" and "Encoding".

So to answer your question how to convert the HEX number E4B8AD, you define the character encoding used as UTF8 and the receiver (maybe some browser), would take this UTF8 stream and decodes it accordingly. If you are writing an application and is receiving this data stream, then you just need to apply UTF8 decoding on that data stream and you should get back the 20013 (2 bytes).

You can read more about character set and encoding at What's the difference between encoding and charset?

Community
  • 1
  • 1
anonymous
  • 1,305
  • 8
  • 7