This is the sort of task that you will never get right if you try to do it yourself. That is, if you try to do it by just doing a bunch of search-and-replaces. The problem is that these formats are too complex and they keep changing (i.e., being "enhanced") day by day.
The right solution is to get a program that does this conversion for you, and let other people be responsible for tracking the minutiae. And the tool you want is "iconv".
Now if you are working under Unix/Linux, you can get this for free. If you're on Windows, you may have to hunt around (but it should be pretty easy to get it running under Cygwin).
Anyway, that's what I would do.