title: How to detect the character encoding of a text file?
body: <p>I try to detect which character encoding is used in my file.</p>
  
  <p>I try with this code to get the standard encoding </p>
  
  <pre><code>public static Encoding GetFileEncoding(string srcFile)
      {
        // *** Use Default of Encoding.Default (Ansi CodePage)
        Encoding enc = Encoding.Default;
  
        // *** Detect byte order mark if any - otherwise assume default
        byte[] buffer = new byte[5];
        FileStream file = new FileStream(srcFile, FileMode.Open);
        file.Read(buffer, 0, 5);
        file.Close();
  
        if (buffer[0] == 0xef &amp;&amp; buffer[1] == 0xbb &amp;&amp; buffer[2] == 0xbf)
          enc = Encoding.UTF8;
        else if (buffer[0] == 0xfe &amp;&amp; buffer[1] == 0xff)
          enc = Encoding.Unicode;
        else if (buffer[0] == 0 &amp;&amp; buffer[1] == 0 &amp;&amp; buffer[2] == 0xfe &amp;&amp; buffer[3] == 0xff)
          enc = Encoding.UTF32;
        else if (buffer[0] == 0x2b &amp;&amp; buffer[1] == 0x2f &amp;&amp; buffer[2] == 0x76)
          enc = Encoding.UTF7;
        else if (buffer[0] == 0xFE &amp;&amp; buffer[1] == 0xFF)      
          // 1201 unicodeFFFE Unicode (Big-Endian)
          enc = Encoding.GetEncoding(1201);      
        else if (buffer[0] == 0xFF &amp;&amp; buffer[1] == 0xFE)      
          // 1200 utf-16 Unicode
          enc = Encoding.GetEncoding(1200);
  
  
        return enc;
      }
  </code></pre>
  
  <p>My five first byte are 60, 118, 56, 46 and 49.</p>
  
  <p>Is there a chart that shows which encoding matches those five first bytes?</p>