Hey everyone! I'm facing a puzzling issue and I can't seem to figure out why it's happening.
I need to download a file that is stored in hex format, so I have to first read it as hex, convert it to binary, and then write it onto an Android/iOS device.
In order to achieve this, in my React project, I read the file from the machine, convert it to binary, and then send it to the native code for writing the file.
This is the code snippet from my React (NOT React Native) project:
Firstly, I read the file:
async readFileContent(path: string, isNotBin = true): Promise<string> {
// Code block for reading the file
}
Next, here's the conversion function:
private hex2bin(hex: string): string | string[] | Uint8Array {
// Conversion logic from hex to bin
}
Finally, sending the content to native code:
viewFile(content: string, fileName: string): Promise<ViewFileResult> {
// Sending content to native code
}
Everything seems fine up until this point. However, when I check the content in the native viewFile function, I notice some weird characters being added unnecessarily (in hex they're equivalent to C2) and the final part of the content is cut off.
Any insights or ideas on what might be causing this issue would be greatly appreciated!