text: public static System.Text.Encoding ParseEncoding(byte[] b){int enc = Encoding(b, 0);if (enc < 0){return Constants.CHARSET;}int lf = NextLF(b, enc);string decoded = Decode(Constants.CHARSET, b, enc, lf - 1);try{return Sharpen.Extensions.GetEncoding(decoded);}catch (IllegalCharsetNameException badName){System.Text.Encoding aliased = CharsetForAlias(decoded);if (aliased != null){return aliased;}throw;}catch (UnsupportedCharsetException badName){System.Text.Encoding aliased = CharsetForAlias(decoded);if (aliased != null){return aliased;}throw;}}