You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
869 B
35 lines
869 B
using Apewer;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace Externals.Compression
|
|
{
|
|
|
|
internal static class Fixed
|
|
{
|
|
|
|
/// <summary>获取用于 Compression 的编码。参照字节数组获取编码,参照无效时获取默认编码。</summary>
|
|
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;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|