Img在字符串编码后将请求结果发送到utf-8

Sorry If I'm doing a duplicate, but I couldn't find the exact solution to my problem. Since I need my page to be displayed in utf-8, I'm currently reading a file into string using a function that I found, and decoding it:

function file_get_contents_utf8($fn) {
 $content = file_get_contents($fn);
  return mb_convert_encoding($content, 'UTF-8',
      mb_detect_encoding($content, 'UTF-8, ISO-8859-1', true));}

After that, I'm echoing that string in my .php file in order to represent the content in my web-page. However, some img tags src parameters have special characters and where I should have a %F3 character results in a %C3%B3, what consequently will cause a 404 error. My questions:
Is there any easy way of getting all my string img src parameters and replace them with the correspondent urlencode?
Am I using the best approach to solve my problem?

Example: After encoding my string where i should have:

<img src="https://path/to/file/Convite%20Lan%E7amento%20do%20livro%20Eletr%F3nica.jpg">

I get:

<img src="https://path/to/file/Convite%20Lan%C3%A7amento%20do%20livro%20Eletr%C3%B3nica.jpg">