It seems like you are only missing <meta charset="UTF-8"> in the <head> part of your HTML. That is, take the HTML you currently generate, place it in <body>...</body> tags, then buryplace the body between <html>...</html>. Finally, add <head><meta charset="UTF-8"></head> before the body (but still inside html).
Browsers tend to assume latin1 encoding when it hasn't been explicitly declared, so what you see is the result of decoding UTF-8-encoded text as Latin-1. Pages of your website have this tag, so they get decoded properly.