Non printable characters are replaced by space characters when copied, how to prevent that from happening?



  • Hi,

    I am trying to edit files that are stored in a custom file format in Notepad++. The format of the files files is not really a text-format, but it has some similarities and Notepad++ is able to display the contents very nicely. I turn on the option to show all characters, so that I can easily see the difference between text characters and other characters that make up te file.
    I do have a problem when copying data around in the editor. When I select a part of the file that contains non-printable characters (with value < 32), these characters will be replaced with a space character (value 32) when pasted somewhere else in the editor. I do not want that, I want the data to be copied without any changes. Is that possible with Notepad++? I did not find an option yet that can do this.

    Ramon



  • @Ramon-Beiboer

    doesn’t seem to happen for me.
    Which npp version do you use? (can be found as debug-info from last menu item the ? menu)

    Can you provide some sample doc/text?



  • @Ramon-Beiboer

    The Edit menu’s Paste Special submenu has some options for copy/paste of binary content. Maybe try these and see if there is any difference?



  • @Alan-Kilborn It looks like the Copy Binary Content and Paste Binary Content commands do the trick! You have to use both binary versions of the copy and paste commands, otherwise it will not copy everything, or mess up the data. I now wonder if this has to do with how the application stores the copied data in the clipboard.
    @Ekopalypse I am using Notepad++ v7.5.6 (64 bit)



  • Hello, @ramon-beiboer, @alan-kilborn and All,

    Yes, Alan is perfectly right about it :-)) I’ve just tried it, opening the notepad++.exe executable file, …in N++, then doing a correct Copy/ Paste operation in a new tab

    • First of all, verify that the part of file to be copied and your new tab have the same encoding

    • Copy your data, using the Edit > Paste Special > Copy Binary Content option

    • Paste your data, in the new tab, using Edit > Paste Special > Paste Binary Content option

    Et voilà :-))

    Best Regards,

    guy038



  • @Ramon-Beiboer said in Non printable characters are replaced by space characters when copied, how to prevent that from happening?:

    I now wonder if this has to do with how the application stores the copied data in the clipboard

    Probably a Scintilla thing. Scintilla often does what it thinks is the “safe” thing with clipboard data.

    Another example is when pasting line-endings. It will paste line-endings appropriate for the current document, regardless of what type of line-endings are in the clipboard. Scintilla is configurable in this regard, but when Notepad++ sets it up, it doesn’t alter this behavior.



  • It seems the NULL char is the problem and now I remember that I read
    somewhere that scintilla handles this differently because of the issue
    that C-Strings a NULL terminated or so (not 100% sure)



  • Seems like Copy/PasteBinary has its origin here.



  • @Ekopalypse Thanks for looking this up. It makes more sense now. I now assigned some keyboard shortcuts to the binary copy and paste commands.


Log in to reply