Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decode binary file in Visual Studio Code programmatically

When trying to open a binary file in Visual Studio Code, the following message will show:

The file will not be displayed in the editor because it is either binary, very large or uses an unsupported text encoding

This is likely a protection to avoid the editor from freezing.

I would love to decode the file before showing it in the editor and have a function ready to handle that. The problem is, that I never have a chance to run my function since the following code never triggers:

vscode.workspace.onDidOpenTextDocument(function (doc) {
    if (doc && doc.fileName.endsWith('.scpt')) {
        console.log("You're trying to open a binary AppleScript file")
    }
});

Unfortunately, the API doesn't provide an equivalent event to onWillSaveTextDocument for opening files, which would fire before the message above shows. Does anybody know of a different solution?

like image 582
idleberg Avatar asked Oct 17 '16 08:10

idleberg


People also ask

How do I run an invs code?

To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and VS Code will try to run your currently active file.


1 Answers

There is an Extension for VSCode called HexDump that you can use to Display a specified file in hexadecimal.

Once installed:

right-click on the file, and select "Show HexDump".

And will display the following:enter image description here

like image 149
glls Avatar answered Sep 28 '22 18:09

glls