Problem
So I have this large text file which contains <0x00>
characters (see picture below).
As you can see on the picture above, I have tryed to remove those characters with a regular expression \x00
. Besides that, I have also tryed \0
and \00
with no success.
However, when I try to replace these characters in Sublime Text, a pop-up shows that these <0x00>
characters indeed have been found (see picture below), so far so good.
Unfortunately, when I click the "replace" button the characters are not replaced.
Question
How can I get rid of these <0x00>
characters?
p.s. It is important to mention that I cannot do a search on "0" since this text file contains zero's, which I would like to remain.
Progress update #1
I have managed to copy a <0x00> char into the "find" search box (see picture below).
However, even when I try to replace this character with an empty character inside the text file no changes occur unfortunately.
Progress update #2 (solution)
Without the helping hand of @00 I wouldn't find the answer to this problem, thank you!
Explanation
The file was encoded in UTF-16, but I assumed it was UTF-8. The file was opened in BOM UTF-8, which was exactly the reason why I was not able to delete the <0x00>
(NUL) characters in Sublime Text 3.
Solution
Execute in 'bash' or in a 'terminal' the following command:
sed -i 's/\x0//g' [textfile_name].txt