Removing "NUL" characters
Asked Answered
E

7

120

I have got characters like that in my notepad++

npp screenshot of NULs

When i am trying to copy whole line, i am actually copying everything until "NUL":

File:1

What i want to do, is replace those null, to be nothing, so i can copy my whole line. Maybe there is any keyword that will tell notepad++(or any other program that might help) to replace those characters? When i am selecting it, use Right Click and then "clear", its gone - but i dont want to do it one by one.

I don't care about removing the cause of this problem, just the effect(NULs)

Evident answered 12/10, 2013 at 10:4 Comment(0)
C
147

This might help, I used to fi my files like this: http://security102.blogspot.ru/2010/04/findreplace-of-nul-objects-in-notepad.html

Basically you need to replace \x00 characters with regular expressions

enter image description here

Chickenhearted answered 12/10, 2013 at 10:6 Comment(3)
Please note, you shuold try "\x00", "\00", or "\0". For me, \x00 and \00 did not work. I needed to use \0 for the replace character.Fosse
@JohnAugust thank you so much for this. \x00 kept finding 'normal' spaces as well as the NUL characters.Spermine
Thx wanted to search a .dmp file for a blok of multi-line text. however unfortunately notepad crashed for me probaly becuase of the size of the dumpLadyinwaiting
A
42

Click Search --> Replace --> Find What: \0 Replace with: "empty" Search mode: Extended --> Replace all

Apollonian answered 13/11, 2014 at 10:39 Comment(2)
What is the extended for??Trollop
@rimiro extended in the sense that specially escaped characters (basic regular expression metacharacters like \n et cetera) can be matched against rather than simply the characters typed.Daryl
W
16

I was having same problem. The above put me on the right track but was not quite correct in my case. What did work was closely related:

  • Open your file in Notepad++
  • Type Control-A (select all)
  • Type Control-H (replace)
  • In 'Find What' type \x00
  • In 'Replace With' leave BLANK
  • In 'Search Mode' Selected 'Extended'
  • Then Click on 'Replace All'
Whitacre answered 15/11, 2017 at 15:57 Comment(1)
Selecting all text (second bullet) is not needed, solution works well with or without it :)Linares
I
7

Try Find and Replace. type \x00 in Find text box, check the Regular expression option. Leave Replace textbox blank and click on replace all. short cut key for find and replace is ctrl+H.

Insectile answered 12/10, 2013 at 10:8 Comment(3)
find with \x00. You may require to check the Regular expression option.Insectile
You have to use a regular expression, this answer is wrong since obviously you can copy past a special char just like thatNigel
I was giving the answer as per SO's question, he is asking on notepad++ not notepad. I dont why people down vote on my answer and other people are upvoiting the answer by AlexShumilov.Insectile
H
4

I tried to use the \x00 and it didn't work for me when using C# and Regex. I had success with the following:

//The hexidecimal 0x0 is the null character  
mystring.Contains(Convert.ToChar(0x0).ToString() );  

// This will replace the character
mystring = mystring.Replace(Convert.ToChar(0x0).ToString(), "");  
Hanfurd answered 5/8, 2016 at 17:14 Comment(2)
What does this have to do with Notepad++?Dichasium
OP asked about notepad++ or any other program that might help. Could you please update the answer with some extra code to make it complete so that it could help others newbie in .Net (i. e. read text file from drive, replace nul chars, save back to text file, I mean something like this, and instructions how to launch C# code without VS, e.g. just using csc.exe).Stedfast
B
2

Open Notepad++
Select Replace (Ctrl/H)
Find what: \x00
Replace with:
Click on radio button Regular expression
Click on Replace All

Booher answered 14/11, 2017 at 19:22 Comment(0)
S
-1

Highlight a single null character, goto find replace - it usually automatically inserts the highlighted text into the find box. Enter a space into or leave blank the replace box.

Snatch answered 12/10, 2013 at 10:8 Comment(1)
This does not work with the NUL character in Notepad++. It does work with many other ASCII special characters, such as BEL, but NUL can only be found using Extended escape codes or RegEx.Nitramine

© 2022 - 2024 — McMap. All rights reserved.