/***********************************************************************
将任意输入的字符串做半角变全角
***********************************************************************/
void half2Full(string source, string &dest){
int i = 0;
dest = "";
while(i < source.length()){
if(source[i] < 0){//中文字符,不处理
dest += source[i++];
dest += source[i++];
}
else if(source[i] >= 33 && source[i] <=126){
dest += 0xA3;
unsigned char ch = (unsigned char)source[i ++] + 128;
dest += ch;
}
else
dest += source[i ++];
}
}
/************************************************************************
全角字符(数字、字母)变半角字符
************************************************************************/
string transform(string str){
int i = 0;
string res = "";
while(i < str.length()){
if(str[i] > 0){
res += str[i];
i ++;
}
else if((unsigned char)str[i] == 163){
res += ((unsigned char)str[i + 1] - 128);
i += 2;
}
else{
res += str.substr(i, 2);
i += 2;
}
}
return res;
}