如题:
void CARD::asc_to_bcd(bcd_buf,ascii_buf,conv_len,type)
unsigned char *bcd_buf,*ascii_buf,type;
int conv_len;
{
int cnt;
char ch,ch1; if( conv_len&0x01 && type )
ch1 = 0;
else
ch1 = 0x55; for(cnt=0; cnt<conv_len; ascii_buf++,cnt++)
{
if(*ascii_buf>='a')
ch=*ascii_buf-'a'+10;
else if(*ascii_buf>='A')
ch=*ascii_buf-'A'+10;
else if(*ascii_buf>='0')
ch=*ascii_buf-'0';
else
ch=0; if(ch1==0x55)
ch1=ch;
else
{
*bcd_buf++ = (ch1<<4)|ch;
ch1=0x55;
}
} if(ch1!=0x55)
*bcd_buf=ch1<<4; return;
}
转成java的代码
void CARD::asc_to_bcd(bcd_buf,ascii_buf,conv_len,type)
unsigned char *bcd_buf,*ascii_buf,type;
int conv_len;
{
int cnt;
char ch,ch1; if( conv_len&0x01 && type )
ch1 = 0;
else
ch1 = 0x55; for(cnt=0; cnt<conv_len; ascii_buf++,cnt++)
{
if(*ascii_buf>='a')
ch=*ascii_buf-'a'+10;
else if(*ascii_buf>='A')
ch=*ascii_buf-'A'+10;
else if(*ascii_buf>='0')
ch=*ascii_buf-'0';
else
ch=0; if(ch1==0x55)
ch1=ch;
else
{
*bcd_buf++ = (ch1<<4)|ch;
ch1=0x55;
}
} if(ch1!=0x55)
*bcd_buf=ch1<<4; return;
}
转成java的代码
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货