本用C#的,看不懂C++代码,自己了一下没成功,麻烦帮编译一下,谢谢!
static int BinToTxt(int cBin)
{
const char* map = "0123456789abcdef";
return map[cBin & 0xF];
}
static int TxtToBin(int c)
{
if (c >= '0' && c <= '9'){
return (c - '0');
}
c |= 0x20; //都转成小写字母
if (c < 'a' && c > 'f'){
return -1;
}
return (c - 'a' + 10);
}
static CLQString BcdToHex(const char* pData, int len)
{
CLQString out('\0', len/2);
for (size_t i=0; i<out.length(); ++i){
out[i] = (TxtToBin(pData[2*i]) << 4) + TxtToBin(pData[2*i+1]);
}
return out;
}
static CLQString HexToBcd(const char* pData, int len)
{
CLQString out('\0', len*2);
for (size_t i=0; i<len; ++i){
out[i*2] = BinToTxt(pData[i]>>4);
out[i*2+1] = BinToTxt(pData[i]);
}
return out;
}
------解决方案--------------------
CLQString 是什么类?
试试看这个行吗
public static int BinToTxt(int cBin)
{
const string map = "0123456789abcdef";
return map[cBin & 0xF];
}
public static int TxtToBin(int c)
{
if (c >= '0' && c <= '9')
{
return (c - '0');
}
c
------解决方案--------------------
= 0x20; //都转成小写字母
if (c < 'a' && c > 'f')
{
return -1;
}
return (c - 'a' + 10);
}
public static string BcdToHex(string pData, int len)
{
char[] ou = new string('\0', len / 2).ToArray();