'a'对应的16进制是 61 转换成 2进制 01100001
0xdf对应的 2进制 11011111 & 01100001 = 01000001 对应的 ASC2 表里的字母 是'A' ,小写转换一样
// 'abc' => 'ABC'
int Lower2Upper(void* sBuff, int slen)
{
unsigned char *bsBuff = (BYTE *)sBuff;
for (int i=0;i<slen;i++) if((bsBuff[i]>='a') && (bsBuff[i]<='z')) bsBuff[i] &= 0xdf;
return true;
}
// 'ABC' => 'abc'
int Upper2Lower(void* sBuff, int slen)
{
unsigned char *bsBuff = (BYTE *)sBuff;
for (int i=0;i<slen;i++) if((bsBuff[i]>='A') && (bsBuff[i]<='Z')) bsBuff[i] |= 0x20;
return true;
}