最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
C++ 处理中文符号实例详解
时间:2022-06-25 04:40:35 编辑:袖梨 来源:一聚教程网
C++ 处理中文符号
英文符号替换为英文逗号
| 代码如下 | 复制代码 |
processPunctuation(string& tag) { std::set punctuation_set.insert(' '); punctuation_set.insert('t'); punctuation_set.insert('');
for(inti=0; i< tag.size(); i++) { if(punctuation_set.find(tag[i]) != punctuation_set.end()) { tag[i] =',' } } return; } | |
中文逗号替换为英文逗号
| 代码如下 | 复制代码 |
processChinesePunctuation(string& tag) { string u8comma = u8","; for(inti = 0; i < tag.size() - u8comma.size() + 1; i++) { boolfind =true; // 查找空格依赖于 UTF-8 的特性 for(intj = 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(intj = 1; j < u8comma.size(); j++) it = tag.erase(it); } } return; } | |
相关文章
- 波比的游戏时间第四章猫捉老鼠通关攻略 07-06
- presentation-skills 本地安装使用教程(新手)(skill安装版) 07-06
- 《息风谷战略》女帝线常见问题解决方法介绍 07-06
- 守护之境孙尚香厉害吗 07-06
- ppt-master skill 先别上正式素材:先查密钥、图片输入和可编辑输出(skill首测版) 07-06
- 星砂岛姜怎么送礼 07-06