大良营销网站建设价格,wordpress服务器配置文件,wordpress 静态缓存,抖音小程序开发者平台qt自动生成的ts文件内部就是用xml写的#xff0c;可以直接用txt文档编辑器打开。想要使用该代码需要更换文件路径#xff0c;使用前可以强制更改后缀名将ts文件改成txt文件。
#include iostream
#include fstream
#include string
#include vec…qt自动生成的ts文件内部就是用xml写的可以直接用txt文档编辑器打开。想要使用该代码需要更换文件路径使用前可以强制更改后缀名将ts文件改成txt文件。
#include iostream
#include fstream
#include string
#include vector
#include iosfwd
#includesstreamint Split(const std::string s, std::vectorstd::string sv, const char delim, int maxSplit 0) {sv.clear();std::istringstream iss(s);std::string temp;int splitCount maxSplit 0 ? INT_MIN : 0;while (std::getline(iss, temp, delim) (splitCount maxSplit)) {sv.emplace_back(std::move(temp));}return static_castint(sv.size());
}int main() {std::string file_name{ };file_name D:Chinese.txt;std::ifstream in_file;in_file.open(file_name.c_str(), std::ios::binary);if (in_file.is_open()) {//打开输出文件file_name D:Chinese.csv;std::ofstream out_file;out_file.open(file_name.c_str(), std::ios::binary);if (out_file.is_open()) {std::string str;std::vectorstd::string str_data;std::vectordouble data;//循环读取ts文件并输出到csv中bool need_endl false;while (std::getline(in_file, str)) {str_data.clear();Split(str, str_data, );//把多行翻译排除if (str_data.size() 3) {str str_data[1];str_data.clear();Split(str, str_data, );if (str_data.size() 2) {if (str_data[0] source) {out_file str_data[1] ,;need_endl true;}else {//判断是否包含tanslation关键字std::vectorstd::string str_trans_symbol;Split(str_data[0], str_trans_symbol, );if (str_trans_symbol[0] translation) {//将翻译中包含的逗号转为空格std::vectorstd::string str_translation;Split(str_data[1], str_translation, ,);for (auto temp : str_translation){out_file temp ;}out_file std::endl;need_endl false;}}}else {if (need_endl) {out_file std::endl;need_endl false;}}}else {if (need_endl) {out_file std::endl;need_endl false;}}}out_file.close();}in_file.close();}
}