最新下载
热门教程
- 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; } | |
相关文章
- 女神漫画免费阅读在线观看最新版本下载安装-女神漫画全集高清完整版免费漫画入口页面 02-10
- 豆包网页版官方入口-豆包AI人工智能在线体验 02-10
- 成何体统电视剧32集全集:高清在线观看(免下载直达) 02-10
- 学科网登录入口-中小学学科网官网电脑版 02-10
- QQ网页版扫码登录入口-QQ网页版文件传输入口 02-10
- 一耽女孩免费漫画阅读软件下载安装手机版-一耽女孩正版免费下载安卓入口 02-10