How to use C# encode and decode 'Chinese' characters

asp.net-mvc, c#, encoding, seo, urlencode

Solution

The text displayed in IE's address bar is the URL encoded form of the hex version of those characters. The hex version of '育儿' encoded in UTF-8 is E882B2E584BF:

byte[] buffer = new byte[] { 0xE8, 0x82, 0xB2, 0xE5, 0x84, 0xBF };
string s = Encoding.UTF8.GetString(buffer);

s is equal to '育儿'.

You shouldn't transmit the straight chinese characters in the URL, it should be URL encoded using HttpServerUtility.UrlEncode and UrlDecode.

Problem

In my ASP.NET MVC application i am using Chinese Category Name, it was displayed as `%E8%82%B2%E5%84%BF` in IE's URL address, but the actual value is '育儿'. I want to know how can I convert '育儿' into `%E8%82%B2%E5%84%BF` in C# and how can I convert it back, too. Is it possible display '育儿' in the URL link directly? Will it be good for SEO?

Original source