using Apewer; using System; using System.Collections.Generic; using System.Text; namespace Externals.Compression { internal static class Fixed { /// 获取用于 Compression 的编码。参照字节数组获取编码,参照无效时获取默认编码。 internal static Encoding GetEncoding(byte[] bytes = null) { // 识别参考数据,判断解压的编码。 if (bytes != null || bytes.LongLength > 0L) { var isUTF8 = TextUtility.IsUTF8(bytes); if (isUTF8) return Encoding.UTF8; // 返回默认编码。 #if NETFX return Encoding.Default; #else return Encoding.UTF8; #endif } // 用于压缩的默认编码。 return Encoding.UTF8; } } }