문제

In one of my database table I found some corrupted words like:

Noël, japón, Świata

Which I later found should be as:

Noël, japón, świata

Anyone know how to convert them back to normal using PHP

도움이 되었습니까?

해결책

Alternatively you can check if the problem is related to the character encoding using iconv - Check the php manual

다른 팁

Unfortunately, it's not revertible by using php conversion. I've just made a PHP script which tries all combinations, more than once (up to 5 times) and none of them yields "japón". So it's not possible.

script:

<?php
$encodings=mb_list_encodings();
foreach($encodings as $enc_to) {
    foreach($encodings as $enc_from) {
        $str="Noël, japón, Świata";
        for ($i=0;$i<5;$i++) {
            $str=mb_convert_encoding($str,$enc_to,$enc_from);
            echo "$enc_from -> $enc_to ($i): ".$str."\n";
            echo "$enc_from -> $enc_to ($i) + html_entity_decode: ".html_entity_decode($str)."\n";
            echo "$enc_from -> $enc_to ($i) + htmlspecialchars_decode: ".htmlspecialchars_decode($str)."\n";
            echo "$enc_from -> $enc_to ($i) + urldecode: ".urldecode($str)."\n";
            echo "$enc_from -> $enc_to ($i) + htmlentities: ".htmlentities($str)."\n";
            echo "$enc_from -> $enc_to ($i) + htmlspecialchars: ".htmlspecialchars($str)."\n";
            echo "$enc_from -> $enc_to ($i) + urlencode: ".urlencode($str)."\n";
        }
    }
}

... grepping the output catches no "japón"

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top