Hex Editor copies wrong values to clipboard
A plugin to improve Notepad++
Brought to you by:
jenslorenz
When copying a sequence of HEX values from the HEX view, bytes having the value of 00 were replaced with value 20 in the clipboard.
Procedure to reproduce the bug.
Notepad++ V. 6.8.6
Hex Editor V. 0.9.5
I've tried this too, but my outputs have been varying. Here's the steps I did on these versions:
Notepad++ 7.5.4
Hex-Editor 0.9.5
Open Notepad++. For repeatability, close all files. You should now have just one tab open that says "new 1" or "new 2".
(As a side note, at this point, in the Encoding tab, my setting is at "Encode in UTF-8". I see a "UTF-8" label in the bottom right corner of Notepad++. After the last bug I was looking into (https://sourceforge.net/p/npp-plugins/bugs/291/), I thought this might be worth putting here, for repeatability purposes.)
Switch to the Hex editor. Type in the following bytes:
00 01 02 03 04
Highlight all 5 bytes. Right-click, and choose "Copy".
Open Notepad. Paste the bytes there.
If you want to repeat these steps, close Notepad++ directly first (don't close any files, for repeatability. just click the red X button). Then open it again, and go back to Step 1.
-From my tests, the output can vary. From some past iterations, I've gotten these sets of outputs on my Notepad:
00 54 94 04 c0
00 54 33 05 c0
00 54 17 05 c0
00 54 1e 05 c0
00 04 20 05 c0
-This is strange. I don't know why this is happening. It may have something to do with the "Autodetect character encoding" feature I commented about in the bug listing I linked above. That's just a pure guess now.
My only other guess is that, with the randomness of these outputs, this may be the cause of some code accessing an array out of bounds and leading to undefined behavior/bytes being gotten. There were a few times where I do the above steps, and when I close Notepad++, it crashes. This may reflect that "out of bounds" undefined behavior, but that's just purely guessing too.
I just came across this bug as well. I have a partition table for a uP and needed to turn it into a byte array in my code. When I paste it into a new Notepad++ file or into my Eclipse editor all the 00 values are now 20. So it seems to be happening on the copy since pasting into different editors also exhibits the bug. I also tried all your examples above and every single one of them turned the 00 into a 20.
Notepad++ v8.2.2
Hex plugin v0.9.12
After some more testing the one thing that I notice is that when I paste the data to a text file the values are pasted with a space between them. To reproduce this type any of the lines above into the Hex view, copy it, create a new file, switch out of hex view and paste the data. Not only will the 00 be converted to 20 but there will be a space between each set of values.
So when the binary values are being copied to the pasteboard there is some sort of conversion happening else there would be no spaces in the text data, it would just be the ascii representation of the binary values all mashed together. Since 0x20 is a space in ascii and it being inserted in between each character, it seems likely that this is where the bug lies.
Last edit: David Lehrian 2022-04-23