Home > Software design >  What is the format of the string displayed when previewing a binary file?
What is the format of the string displayed when previewing a binary file?

Time:04-09

I have a file I want to download that is displayed as a preview in a webview. I can access the html content of the webview from outside of it. I would like to save the file that is being previewed as a binary file. Given document.body.innerHTML, is there any way to recover the binary data or I need the original data from the request?

The preview looks something like this enter image description here

Thanks for any help

CodePudding user response:

"What is the format of the string that is being displayed" - The browser has done it's best to render the binary data as if it was a unicode encoded string, probably UTF-8.

It's possible/likely that here are byte sequences that do not match up to valid unicode characters, depending on the exact encoding used. This will cause those sequences to be replaced by a unicode replacement character preventing the original binary data from being recoverable from the preview.

Your best bet bet would be to retreive the original data.

  • Related