In CAPL code, I have a "byte[]" array, this array is supposed to hold "Hex" values (00..FF).
The problem is that, when I try to save the "Hex" array to a file in "ASCII" format, it completely ignores "00" (which is the "NULL" character) resulting in corrupting the output file.
variables
{
byte UploadedData[56, 41, 4C, 00, 01, 02, 00, 02];
char ExportedTextFile[9];
char FileName[32] = "FlasherImage.can";
dword FileHandle = 0;
}
void ExportDataFile(void)
{
int u16Index = 0;
FileHandle = OpenFileWrite(FileName, 0);
for (u16Index = 0; u16Index < 8; u16Index++)
{
snprintf(ExportedTextFile, elcount(ExportedTextFile), "%c", UploadedData[u16Index]);
filePutString(ExportedTextFile, elcount(ExportedTextFile), FileHandle);
}
fileClose(FileHandle);
}
The Expected File Shall Be: VALNULSOHSTXNULSTX
The Obtained File is ("NUL" is ignored): VALSOHSTXSTX
where: V: Character 'V'. A: Character 'A'. L: Character 'L'. NUL: "NULL" Control Character. SOH: "Start Of Header" Control Character. STX: "Start of Text" Control Character.
Please, help me with any solution or workaround.
Thank you very much.