源代码在: https://github.com/pzhu1015/easycpp编译要求:因为代码中将数据字典转成了二进制文件并压缩减少执行文件大小用到了两种压缩方案,1. -llzma (压缩率高)2. -lz (压缩率一般)默认 使用第一种如果要使用第二种可以定义宏: -DPHONEDATA_GZIP代码使用中只需要#include phonedata.h, 这个文件会自动根据当前环境要求选择使用哪种压缩的数据, phonedata.h为查询算法, 还有两个数据文件phone_xz.h, phone_gz.h。数据来源phone_data: 手机号归属地查询 (gitee.com)归属地信息库文件大小4557kb归属地信息库最后更新2025年02月手机号段记录条数517258具体用法如下:#include phonedata.h void TestPhoneData() { std::vectorstd::string numbers { 15695866526, 18069202072, 13819813415, 15306627776, 13355915301, 13262429999, 15824205247, 18167219893, 15968925439, 15051515852, 80901142, }; for (const auto number: numbers) { auto pr phonedata::PhoneData::Instance()-Find(number); if (!pr) { ERROR(未找到此手机号信息); return; } INFO([%s][%s-%s][%s], pr-Number.data(), pr-Province.data(), pr-City.data(), pr-CardType.data()); } } 输出结果: [15695866526][浙江-宁波][中国联通] [18069202072][浙江-宁波][中国电信] [13819813415][浙江-宁波][中国移动] [15306627776][浙江-宁波][中国电信] [13355915301][浙江-宁波][中国电信] [13262429999][浙江-温州][中国联通] [15824205247][浙江-宁波][中国移动] [18167219893][浙江-宁波][中国电信] [15968925439][浙江-宁波][中国移动] [15051515852][江苏-苏州][中国移动] 未找到此手机号信息