stef-levesque / vscode-hexdump

hexdump for Visual Studio Code
MIT License
138 stars 27 forks source link

'copyAsHexString' fails when vscode doesn't recognize the characters #55

Closed armarti closed 5 years ago

armarti commented 5 years ago

I just installed this in order to see the hex representation of some odd bytes in a big file and it seems it doesn't work.

I'm trying the command "copy the buffer selection as hexadecimal string" with the 4th <?> highlighted in the photo below: image

I think I'll need to dump the whole file as hex and search for the bytes, so it'd be super if this could work :)

armarti commented 5 years ago

Turns out they're a bunch of null bytes 0x0. I'm on Windows and it seems from the clipboardy issues there are problems dealing with Windows' clipboard, e.g. https://github.com/sindresorhus/clipboardy/issues/25#issuecomment-309353051

stef-levesque commented 5 years ago

Thanks for looking into it. I'll look to use the new VSCode API for using the clipboard https://github.com/Microsoft/vscode/blob/003521e715f2dbcf4f98be99a923097505859954/src/vs/vscode.d.ts#L5899

Hopefully, this should solve this issue.

stef-levesque commented 5 years ago

Ok, i thing I see the confusion here.

The command copyAsHexString should only be available when using a hexdump editor.

Make sure to open your file in a hexdump editor using the command palette, or the icon on the top-right corner. Then, make your selection either in the hexadecimal or ASCII section, then call the copyAsHexString command. This should work fine, as those gets converted to ASCII characters before getting passed to the clipboard.

Let me know if this fix your problem.

armarti commented 5 years ago

Yeah that's fine.Maybe this is an enhancement request then. It'd be neat if I could highlight something in a text document and copy the hex representation for whatever is highlighted.