一、把QQ群的聊天记录txt格式导出
消息管理器 -> 选择要导出的群 -> 右击、导出
这里要注意 : 导出之后的 文本是 unicode 编码的,需要转换 ==|| 之前不知道,搞了大半天。
重新建一个txt , 把原来的 txt 内容 复制 到 新的 txt ,保存就行了。
二、详细代码
1. head.h
1 #ifndef TxtSearch 2 #define TxtSearch 3 4 #include<string> 5 #include<map> 6 #include<set> 7 #include<iostream> 8 #include<vector> 9 #include<fstream> 10 #include<sstream> 11 #include<ctype.h> 12 13 typedef unsigned char BYTE; 14 typedef unsigned short WORD; 15 16 bool IsChineseChar(WORD DoubleByte); 17 18 void WordAndChar_print(std::string ); 19 20 21 class TextQuery 22 { 23 public: 24 25 typedef std::vector<std::string>::size_type line_no; 26 27 void read_file(std::ifstream & ); 28 std::set<line_no> run_query(const std::string&) const; 29 std::string text_line(line_no) const; 30 private: 31 void store_file( std::ifstream & ); 32 void build_map(); 33 34 35 std::vector<std::string> lines_of_text; 36 std::vector<std::string> bak_lines_of_text; 37 std::map< std::string,std::set<line_no> > word_map;