Конвертировать utf8 в latin1 в PHP. Все символы выше 255 преобразуются в ссылки на символы

Мне нужно преобразовать текст в UTF-8 в текст, закодированный в ISO-8859-1, чтобы любой символ, не являющийся частью набора ISO-8859-1, превратился в ссылку на символ. (например,β)

Пример: я хочу превратить текст как

hello é β 水

в

hello é β 水

Я делаю все это на PHP. Я попробовал встроенные функции, iconv, tidy и их комбинацию, но до сих пор не могу найти надежного решения.

Вот что у меня так далеко

// convert any characters fount in the entity table into HTML entities
// do not double encode entities, do not mess with quotes
// use UTF-8 as character encoding because the page submits UTF-8
$str = htmlentities($str,ENT_NOQUOTES,'UTF-8',false);
//print $str."\n";

// convert text from UTF-8 to ISO-8859-1, 
// characters that cannot be converted will be converted to ?
$str = utf8_decode($str);
//print $str."\n";    

// make string XML valid.
// mainly it converts text entities into numeric entities.
$opts = array(  "output-xhtml"      => true, 
            "output-xml"        => true, 
            "show-body-only"    => true,
            "numeric-entities"  => true,
            "wrap"              => 0,
            "indent"            => false,
            "char-encoding" => 'latin1'
        );
$tidy = tidy_parse_string($str, $opts,'latin1');
tidy_clean_repair($tidy);
$str = tidy_get_output($tidy);      
//print $str."\n";

Ответы на вопрос(1)

Ваш ответ на вопрос