国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C++ > 正文

C++ 處理中文符號實例詳解

2020-05-23 13:56:17
字體:
來源:轉載
供稿:網友

C++ 處理中文符號

英文符號替換為英文逗號

processPunctuation(string& tag){  std::set<char> punctuation_set;  punctuation_set.insert(' ');  punctuation_set.insert('/t');  punctuation_set.insert(';');  for (int i=0; i< tag.size(); i++) {    if (punctuation_set.find(tag[i]) != punctuation_set.end())     {      tag[i] = ',';    }  }  return;}

中文逗號替換為英文逗號

processChinesePunctuation(string& tag){  string u8comma = u8",";  for (int i = 0; i < tag.size() - u8comma.size() + 1; i++)  {    bool find = true;    // 查找空格依賴于 UTF-8 的特性    for (int j = 0; j < u8comma.size(); j++)    {      if (tag[i + j] != u8comma[j])      {        find = false;        break;      }    }      if (find)    {      // 替換為 ,      tag[i] = ',';      auto it = tag.begin();      it += i + 1;      for (int j = 1; j < u8comma.size(); j++)        it = tag.erase(it);    }  }  return;}

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 香格里拉县| 宁明县| 聂荣县| 无锡市| 涟源市| 海丰县| 嘉禾县| 惠东县| 新巴尔虎左旗| 响水县| 千阳县| 康保县| 准格尔旗| 资兴市| 中方县| 岫岩| 仙居县| 礼泉县| 兴安盟| 马公市| 丰宁| 泰宁县| 宁津县| 昌吉市| 扎囊县| 辽阳县| 馆陶县| 中方县| 娱乐| 仪陇县| 舟曲县| 海城市| 元朗区| 闻喜县| 友谊县| 垦利县| 邯郸市| 闵行区| 铜鼓县| 社会| 肃宁县|