I have problems with Converting unsigned char to CString and reversely, converting the result of converted CString to unsigned char.
first, I try to using CString.append();.
///////////////////////////
CString result2;
CString result3;
unsigend char unchar_result[9];
unchar_result = {143, 116, 106, 224, 101, 104, 57, 157};
unchar_result[8] = NULL;
for(int i=0; i<8; i++){
result2=(char)temp[i];
result3.append(result2);
}
//////////////////////////
as a result, I think result3 was correctly substituted.
if I saw 'unchar_result' by the ASCII code, then unchar_result = "?tj?eh9?" and result3 was "?tj?eh9?" too.
But I want to reversely convert (CString)result3 to unsigned char matrix.
unsigned char a;
unsigned char testdecode[8];
for(int i=0; i<8 ; i++){
a=result3.GetAt(i);
testdecode[i]=a
}
after converting, the result was "?tj?eh9?" but, the value was { 63, 116, 106, 63, 101, 104, 57, 63}... i expect the result was { 143, 116, 106, 224, 101, 104, 57, 157 }.
next, I try again using CStringA.
CStringA result6;
result6(unchar_result);
and I can see the value through the local variable window of the debug tool. then, result6 was "뢶j?h9앀儆?" moreover int len = result6.GetLength() = 13.
How to correctly convert unsigned char to CString and to do inverse?