Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy HEX values to other programs #341

Open
GhostScript0r opened this issue Feb 19, 2022 · 13 comments
Open

Copy HEX values to other programs #341

GhostScript0r opened this issue Feb 19, 2022 · 13 comments
Labels
feature request Issues related to new features users want

Comments

@GhostScript0r
Copy link

I just recently noticed that I cannot copy the HEX value "as shown" to other editors. For example when I copy the following content

image

I get the following text, which is neither the HEX value nor the text after UTF encoding.
//79/1AATgBHAA0ACgANAAoAGgANAAoAAAAAAAAADQAKAEkASABEAFIAAAAAAAcA/f8AAAAABAD9/wgABgAAAAAAAAD9/yQAfgQAAAAAAAABAHMAUgBHAEIAAAD9//3/HAD9/wAAAAAAAAQAcwBCAA==

@connor4312
Copy link
Member

The copied value is the base64 representation of the bytes

@tkuraku
Copy link

tkuraku commented Apr 22, 2022

Is it possible to change it so that you can copy and paste the hex values as text to and from the editor window? That would be very helpful.

@lorsanta
Copy link
Contributor

Hi! I was reading the code to find a way to solve this issue, but there's something I don't understand.
Why in hexEditorProvider.ts the copied selection is base64 encoded, and not encoded as a hex string? To be clearer why can’t we do something like this?

--- a/media/editor/copyPaste.tsx
+++ b/media/editor/copyPaste.tsx
const decode: { [key in Encoding]: (data: string) => Uint8Array } = {
-	[Encoding.Base64]: d => base64.toUint8Array(d),
+	[Encoding.Base64]: d => Uint8Array.from(d.split(" ").map((byte) => parseInt(byte, 16))),
 	[Encoding.Utf8]: d => new TextEncoder().encode(d),
 };
--- a/src/hexEditorProvider.ts
+++ b/src/hexEditorProvider.ts
	const parts = await Promise.all(message.selections.sort((a, b) => a[0] - b[0]).map(s => document.readBuffer(s[0], s[1] - s[0])));
	const flatParts = flattenBuffers(parts);
-	const encoded = message.asText ? new TextDecoder().decode(flatParts) : base64.fromUint8Array(flatParts);
+	const encoded = message.asText ? new TextDecoder().decode(flatParts) : Array.from(flatParts).map(byte => byte.toString(16).padStart(2, "0")).join(" ");
	vscode.env.clipboard.writeText(encoded);

What am I missing?

@lramos15
Copy link
Member

I believe we went with base64 due to the hex editor being tightly coupled with debugging in certain scenarios.
cc @connor4312

@jnz86
Copy link

jnz86 commented Aug 10, 2023

Another request for an option to not use Base64. It makes no sense for most use cases. If I copied AA BB CC I need that. I almost will never need qrvM.

I'm sure that some situations would require that, and I think it's fine to treat it that way on the backend, but when a user copies the result should be to user desirable data.

@hakanai
Copy link

hakanai commented Aug 10, 2023 via email

@Manouchehri
Copy link

This is a huge problem when debugging C++... I can't think of a single time where I wanted to copy base64 from memory instead of hex..

@NessDan
Copy link

NessDan commented Feb 22, 2024

Any update on this? I've had to use a 3rd-party website (hexed.it) to copy byte values.

image

@msojocs
Copy link

msojocs commented Feb 29, 2024

bad extension.

I found an extension:

https://marketplace.visualstudio.com/items?itemName=slevesque.vscode-hexdump

You should install it by "Install from VSIX".

image

@BurningEnlightenment
Copy link

I can't think of a single time where I wanted to copy base64 from memory instead of hex..

Manually constructing a PEM file from a DER file is my only use case so far (I agree that a hex encoded copy is usually more useful).

@OhThomas
Copy link

OhThomas commented Aug 5, 2024

Any plans on implementing this?

@lorsanta
Copy link
Contributor

lorsanta commented Aug 6, 2024

Any plans on implementing this?

It's already been implemented but the mainteiners are probably busy right now, that's why they haven't release a version with the patch yet

@BodyCSoulN
Copy link

Any plans on implementing this?

It's already been implemented but the mainteiners are probably busy right now, that's why they haven't release a version with the patch yet
Sad... It is really an useful functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues related to new features users want
Projects
None yet
Development

No branches or pull requests