Printer Printer
来源:互联网 发布:臭美评分软件下载 编辑:程序博客网 时间:2024/04/30 15:08
int PrintLine( CString strData ) //command + data + end{//20 08 08//Data + 0D 0Aint i, len;char buf[1024] = {0};char hexData[1024] = {0};BYTE input[3] = { 0X20, 0X08, 0X08 };BYTE output[100] = {0};CString str, str1;len = strData.GetLength();memcpy( buf, strData, len );for( i=0; i<len; i++ ){str1.Format( "%02X", buf[i] ); //char --> 字节数组str += str1;}str += "0D0A0000";len = str.GetLength();memset( buf, 0, sizeof( buf ) );memcpy( buf, str, len );StrToEBCD( buf, hexData, len );//89860099--->0x89,0x86,0x00,0x99 ///////////} //convert string into EBCDint StrToEBCD( char *buf, char *ucBuffer, int BufLen ) //89860099--->0x89,0x86,0x00,0x99{ unsigned char temp1,temp2; int Len=BufLen/2,i; for( i=0; i<Len; i++ ) { temp1=buf[i*2]; if( temp1>='a' ) temp1=temp1 - 'a' + 10; if( temp1>='A' ) temp1=temp1 - 'A' + 10; if( temp1>='0' ) temp1=temp1-'0'; temp2=buf[i*2 + 1]; if( temp2>='a' ) temp2=temp2 - 'a' + 10; if( temp2>='A' ) temp2=temp2 - 'A' + 10; if( temp2>='0' ) temp2=temp2-'0'; ucBuffer[i]=((temp1&0x0f)<<4)|(temp2&0x0f); } return 0;}