Alex Rivera | Logout

How can I clean source code files of invisible characters?

Asked 2009-07-01T07:30:26.400
40

I have a bizarre problem: Somewhere in my HTML/PHP code there's a hidden, invisible character that I can't seem to get rid of. By copying it from Firebug and converting it I identified it as  or 'Zero width no-break space'. It shows up as non-empty text node in my website and is causing a serious layout problem.

The problem is, I can't get rid of it. I can't see it in my files even when turning Invisibles on (duh). I can't seem to find it, no search tool seems to pick up on it. I rewrote my code around where it could be, but it seems to be somewhere deeper in one of the framework files.

How can I find characters by charcode across files or something like that? I'm open to different tools, but they have to work on Mac OS X.

Edit
Report

1 Answer

15

If you are using Textmate and the problem is in a UTF-8 file:

  1. Open the file
  2. File > Re-open with encoding > ISO-8859-1 (Latin1)
  3. You should be able to see and remove the first character in file
  4. File > Save
  5. File > Re-open with encoding > UTF8
  6. File > Save

It works for me every time.

answered 2010-06-21T14:52:09.490

Your Answer