It looks like PHP has nothing to do with the error message right from "getaddrinfo failed:". Misrepresented characters come from different sources - here from the ftp server. You checked both the web server and PHP, but not the ftp server configuration.
It would be best to check the ftp server.
You can check another error message below your code
header("Content-Type: text/html; charset=utf-8"); ftp_connect("1"); //generate some mess resulting in error info file_get_contents('forsurenonexistingfile');
if your error information falls into the correct representation of the character, the mystery is gone.
source share