PHP latin1 için utf8 dönüştürün.

0 Cevap php

Ben ISO-8859-1 kodlanmış metnin içine UTF-8 metin dönüştürmek için gereken ISO-8859-1 set parçası olmayan herhangi bir karakter karakter başvuruları dönüşecekti böyle. (Ex β)

Örnek: Ben gibi metin çevirmek için istiyorum

hello é β 水

içine

hello é β 水

PHP tüm bu yapıyorum. Ben yerleşik işlevleri, iconv ve derli toplu ve bunların kombinasyonunu denedim ve hala cant güvenilir bir çözüm olsun.

İşte ben bugüne kadar ne var

// convert any characters fount in the entity table içine 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 içine 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";

0 Cevap