chcg / NPP_HexEdit

Notepad++ Plugin Hexedit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Copy/paste changes 00 to 20

hoensr opened this issue · comments

If I copy some hex from the HexEdit plugin to the clipboard and paste it somewhere else, "00" bytes are changed to "20".

image

image

image

I use the newest HexEdtor 0.9.5.19 (2018-02-11) with Notepad++ 7.8.2.

Also, if I copy not the hex digits, but something from the right-hand side, and paste it, an additional space character is appended. Shall I open a separate issue about this?

Related question: does HexEdit support copying the whole set of hex digits of a given text?

The same behaviour applies to the search dialog (ctrl-F). Hex values "30 00 35 00 35 00 33 00" can be searched for when entered manually into dialog box.
Notepad++ v7 8 6   (64-bit)hex_find(manually_entered)
When selecting the same Hex values in the edit window, the dialog box shows 20 istead of 00 (30 20 35 20 35 20 33 20) and consequently doesn't find the desired values:
Notepad++ v7 8 6   (64-bit)hex_find(marked_in_edit_area)

Debug info: Notepad++ v7.8.6 (64-bit)
Build time : Apr 21 2020 - 15:23:03
Path : C:\Program Files\Notepad++\notepad++.exe
Admin mode : OFF
Local Conf mode : OFF
OS Name : Windows 10 Pro (64-bit)
OS Version : 1909
OS Build : 18363.778
Plugins : HexEditor.dll HTMLTag.dll mimeTools.dll NppConverter.dll NppExport.dll
Using: HexEditor_0.9.6_x64.zip

Added a similar bug in Notepad++ as it has the same behaviour, and I suspect the bugs are related.

So, further investigation. Seems it might be a scintilla "feature" that was introduced in 2013.
One workaround for notepad++ suggests using the Edit > Paste Special > Copy Binary Content menu in notepadd++.

image

However, this menu isn't available in the Hex-Editor plugin.

So, I suggest the best fix for Hex-Editor is:

  1. Enable the paste special menu
  2. Just make use of the underlying notepad++ code to copy binary content rather than the standard copy/paste.

I would get involved and try and fix this, as it looks interesting, but I am not great at C++!

However, having a quick look, I think a good start would be in the ModifyMenu.cpp file. A custom Edit menu is created, which includes IDM_EDIT_COPY.

For starters, I think the menu should at least include IDM_EDIT_COPY_BINARY, IDM_EDIT_CUT_BINARY and IDM_EDIT_PASTE_BINARY, which would provide a workaround.

Probably these should be used instead of the standard Copy, Cut, Paste.

Ok. Got it working. Code is a bit janky though, so will clean it up first.

image
image

I have done a pull request with a fix for this.
image

Thank you very much!

commented
commented

"Copy binary content" doesn't work for me, and only the first byte of the selection gets pasted.

Any more info or steps to reproduce?

commented

Not really much?
Open any non-text file and click the button while selecting anything with 00 inside.
Depending on what pasting action you then use, the string will either stop before the first 00 or after the last 00.

N++ is 8.4.8 and the plugin is 0.9.12 if it can help.

I am on a different machine right now. I can try and look later. Does ver 0.9.11 work for you? Or the version I forked?

commented

There's no binary release there, and 0.9.11 is blacklisted on newer npp versions