VC 判断CString字符串中各位是数字,大小写字母,符号,汉字

时间:2022-05-04 09:12:42
// UNICODE字符集

CString str =  L"0123abc中文字符、/";  

CString shuzi,biaodianfuhao,hanzi,daxiezimu,xiaoxiezimu;  
  
for (int i = 0 ; i <str.GetLength();i++)  
{  
 int unicode = (int)str.GetAt(i);  
 if (unicode <= "9" && unicode >= "0")  
 {  
  shuzi += str.GetAt(i);  
 }  
 else if (unicode <= "z" && unicode >= "a")  
 {  
  xiaoxiezimu += str.GetAt(i);  
 }  
 else if (unicode <= "Z" && unicode >= "A")  
 {  
  daxiezimu += str.GetAt(i);  
 }  
 else if (unicode > 255)  
 {  
  hanzi += str.GetAt(i);  
 }  
 else  
 {  
  biaodianfuhao += str.GetAt(i);  
 }  
}  


转载自:

http://blog.163.com/pirates_fish/blog/static/183333150201111221034325/