I have to update a website with a lot of files. I am using Textmate's Find in project to replace text with a massive regular expression.

The problem is: the files are saved on a windows machine in ISO-8859-1 (Windows). Textmate likes to look at files as MacRoman or UTF-8. So, special characters such as curly quotes get replaced by bits of evil.

When I use Reopen file with encoding it reads the file fine. But when I apply a change using Find in project and then issue Save all files all the files get saved with the wrong encoding, leading to a lot of bad characters.

Has anyone any idea how to prevent this and make sure all the files are read and saved with the right encoding?

link|improve this question
feedback

2 Answers

up vote 1 down vote accepted

I think Textmate can't do this so you might want to do command line replacements using Sed,
or look for an alternative editor that does handle encoding properly.

link|improve this answer
TextMate preferences does have an option to change the default encoding. I don't see why that wouldn't work. – ghoppe Aug 11 '10 at 16:33
@ghoppe: me neither, but it seems to be ignored. – avdgaag Aug 11 '10 at 19:46
feedback

Have you tried opening the TextMate preferences under the Advanced tab? There is a popup for File Encoding: where you can choose the default encoding. ISO-8859-1 is available.

Underneath the popup there's a checkbox that says Use for existing files as well — have you checked that box?

link|improve this answer
Yes I have. Setting that to the correct encoding does indeed work well when opening a file. But this is not respected when modifying files without opening them, as 'Save all files' does. – avdgaag Aug 11 '10 at 19:45
@avdgaag See my edit. Is that checkbox selected as well? – ghoppe Aug 11 '10 at 22:47
yes it is. – avdgaag Aug 12 '10 at 19:04
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.