在编程时遇到很多ASCII码....很难理解!

来源:百度知道 编辑:UC知道 时间:2024/05/30 11:49:21
在看别人的程序时经常碰到很多ASCII码..读的头晕..怎么办?比如:

if( (iLen == 1) && (acInfo[0] == 0x0a) )
acInfo[0] = 0x0d;
if( acInfo[0]<0x20 && (acInfo[0]!=0x0d && acInfo[0]!=0x08&& acInfo[0]!=0x0a) )/*0x0d:ret; 0x08:backspace*/
{
EwgMessage oMsg;
if( !(acInfo[0]==0x03 || acInfo[0]==0x11 || acInfo[0]==0x13 || acInfo[0]==0x1a) return 0;
printf("Send Cmd-%x directly\n", acInfo[0] );
if( acInfo[0] == 0x03 )
ResetPortQue( iPortNo );
oMsg.m_cPort = iPortNo+1; /*port in the H20-20 is based 1 rather than 0*/
oMsg.m_cType = eMsgPortInfo;
memset( oMsg.m_acInfo, 0, sizeof(oMsg.m_acInfo) );
strncpy( oMsg.m_acInfo, acInfo, 1 );
SendMsgToDrv( &oMsg );
return 0;
}

0x0a ='\n'
0x20 =' '
0x08=backspace
查ASCII表去

如果你的对十六进制不熟悉,可以看的时候转换成十进制撒,用windows的计算机轻松搞定。转换完了作为注释写上,就像你第一句那样

既然是看别人的代码,那是没有办法的事情啊,要不怎么说宁可自己重新写也不愿看别人的代码呢——当然是对风格不好的代码