Cannot replace null with space

I have a fixed width text file which has some null characters in no particular order. I need to replace them with spaces so that the width remains same.

I tried this:

tr  "\000" "\040" < mainfile > newfile

Does not work. I tested that it works the other way round:

$ echo "hello" |tr "l" "\000" > b
$ less b
he^@^@o

So tr is able to convert to null but cannot convert back from it. I have tried the typical sed/awk commands w/o any results. The null control characters are visible only when I use utilities like less/vim etc.

Any ideas?

perl did it for me:

perl -pe 's/\000/ /g' oldfile > newfile

Seems like sed on Solaris suffers from this specific issue.