Heres how I might approach it. Are there a manageable number of URLs that you need to replace? If so I would build a regular expression that looked for the incorrect url and replaced it with the correct one for each url that you have. Then I would open a file pointer (fopen) to the file and read each line in and then run the string replace function (ereg_replace) using the regular expression.
If you don't have a limited number of urls and you want to replace characters only, I would still open an file pointer and read in each line, then I would look for any occurences of <a href=" and then take in all the character from the beginning quote until the next ending quote " and store them into an array. That way you will know that you are dealing with a link text and not a display text. Then I would create a function that looped through the array and replaced any non standard HTML characters with their substitutes. This function then could return a corrected string which you would place back into the appropriate spot.
Drew