C#和VB.NET检测文件编码的一个库

作者在 2018-06-06 00:36:52 发布以下内容

https://www.nuget.org/packages/SimpleHelpers.FileEncoding/

安装方式:

111.png (上传于2018-06-06 00:36:52)
111.png
作者在 2018-06-06 09:40:40 补充以下内容

示例:

public static void Main(String[] args)
{
    string filename = args[0];
    using (FileStream fs = File.OpenRead(filename)) {
        Ude.CharsetDetector cdet = new Ude.CharsetDetector();
        cdet.Feed(fs);
        cdet.DataEnd();
        if (cdet.Charset != null) {
            Console.WriteLine("Charset: {0}, confidence: {1}", 
                 cdet.Charset, cdet.Confidence);
        } else {
            Console.WriteLine("Detection failed.");
        }
    }
}

Windows | 阅读 2673 次
文章评论,共0条
游客请输入验证码
浏览2795618次
文章归档