编码识别-使用gcc在linux中编译google/compact_enc_det

compact_enc_det是google的开源编码检测项目,开源与github:

https://github.com/google/compact_enc_det.git

compact_enc_det可以用来检测给定的文本文件的编码类型,支持多种类型的文本:

enum TextCorpusType {
  WEB_CORPUS,
  XML_CORPUS,
  QUERY_CORPUS,       // Use this for vanilla plaintext
  EMAIL_CORPUS,
  NUM_CORPA,          // always last
};

其主要的检测编码的方法描述如下:

Encoding DetectEncoding(
      const char* text, int text_length, const char* url_hint,
      const char* http_charset_hint, const char* meta_charset_hint,
      const int encoding_hint,
      const Language language_hint,  // User interface lang
      const TextCorpusType corpus_type, bool ignore_7bit_mail_encodings,
      int* bytes_consumed, bool* is_reliable);
在linux上将这个 项目编译成 动态链接库的步骤如下:

1. 下载代码:git clone https://github.com/google/compact_enc_det.git

2.  进入项目目录 cd compact_enc_det/

3.  执行编译命令 :

g++ -shared -Wno-narrowing -fPIC -o encod.so ./compact_enc_det/compact_enc_det.cc ./compact_enc_det/compact_enc_det_hint_code.cc ./util/encodings/encodings.cc ./util/languages/languages.cc -I ./ --std=c++11

此文不介绍 g++命令细节哦

到此就可以得到 encod.so 文件,这个文件就是我们要用的动态链接库文件。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值