title: Can we simplify this string encoding code
body: <p>Is it possible to simplify this code into a cleaner/faster form? </p>
  
  <pre><code>StringBuilder builder = new StringBuilder();
  var encoding = Encoding.GetEncoding(936);
  
  // convert the text into a byte array
  byte[] source = Encoding.Unicode.GetBytes(text);
  
  // convert that byte array to the new codepage. 
  byte[] converted = Encoding.Convert(Encoding.Unicode, encoding, source);
  
  // take multi-byte characters and encode them as separate ascii characters 
  foreach (byte b in converted)
      builder.Append((char)b);
  
  // return the result
  string result = builder.ToString();
  </code></pre>
  
  <p>Simply put, it takes a string with Chinese characters such as 鄆 and converts them to ài.</p>
  
  <p>For example, that Chinese character in decimal is 37126 or 0x9106 in hex. </p>
  
  <p>See <a href="http://unicodelookup.com/#0x9106/1" rel="nofollow noreferrer">http://unicodelookup.com/#0x9106/1</a></p>
  
  <p>Converted to a byte array, we get [145, 6] (145 * 256 + 6 = 37126).  When encoded in CodePage 936 (simplified chinese), we get [224, 105]. If we break this byte array down into individual characters, we 224=e0=à and 105=69=i in unicode. </p>
  
  <p>See <a href="http://unicodelookup.com/#0x00e0/1" rel="nofollow noreferrer">http://unicodelookup.com/#0x00e0/1</a>
  and
  <a href="http://unicodelookup.com/#0x0069/1" rel="nofollow noreferrer">http://unicodelookup.com/#0x0069/1</a></p>
  
  <p>Thus, we're doing an encoding conversion and ensuring that all characters in our output Unicode string can be represented using at most two bytes. </p>
  
  <p>Update: I need this final representation because this is the format my receipt printer is accepting. Took me forever to figure it out! :) Since I'm not an encoding expert, I'm looking for simpler or faster code, but the output must remain the same. </p>
  
  <p><strong>Update (Cleaner version):</strong> </p>
  
  <pre><code>return Encoding.GetEncoding("ISO-8859-1").GetString(Encoding.GetEncoding(936).GetBytes(text));
  </code></pre>