2010-06-29 2 views
0

나는 phr cli 스크립트를 폴더를 통해 이동하려고하는데, id3 태그는 키릴 문자로 utf8에 있지만 데이터베이스에는 있지만. 내가 스크립트를 실행할 때 내가 "Àëáåíà"cli 스크립트 id3 태그를 읽는 인코딩의 PHP 문제

같은 DB 필드에 원시 UTF 여기에 2 일이 발생했다 나의 특별한 경우 스크립트

<? 
set_time_limit(0); 

include('classes/adodb5/adodb.inc.php'); 
include ('classes/id3/getid3.php'); 

$ftpdir = "/radio/unprocessed/"; 
$processeddir = "/radio/music"; 

//set up the database 

$conn = &ADONewConnection('mysql'); 
$conn->PConnect('localhost','root', '**********','radio'); 

$utf = $conn->Execute("SET NAMES 'UTF8';"); 
$charset = $conn->Execute("CHARSET UTF8;"); 

//function for processing the actual file 
function processmp3($fn, $folder, $conn){ 
         $getID3 = new getID3; 
         $ThisFileInfo = $getID3->analyze($folder.$fn); 
         //this is needed to consolidate all tag formats 
         getid3_lib::CopyTagsToComments($ThisFileInfo); 
         if (array_key_exists('artist', $ThisFileInfo['comments_html'])&& array_key_exists('artist', $ThisFileInfo['comments_html'])){ 
           $artist=($ThisFileInfo['comments_html']['artist'][0]); 
           $title=($ThisFileInfo['comments_html']['title'][0]); 
         }else{$artist ='not defined'; $title="not defined";} 
         //random name 
//random name 
         $rand_name = md5(time()).rand(1,1000).".mp3"; 
         //movefile 
         //rename($folder.$fn,'/radio/music/'.$rand_name); 
         //put in DB 
         $insert = $conn->Execute('INSERT INTO unprocesseds VALUES("","'.$artist.'","'.$title.'","'.$rand_name.'","'.$fn.'");'); 
         } 


//cyccle through contents 
if($handle = opendir($ftpdir)){ 
     while(false !== ($file = readdir($handle))){ 
       $type = mime_content_type($ftpdir.$file); 
       if ($type=='audio/mpeg'){processmp3($file, $ftpdir, $conn);} 
       else { 
         if(is_file($ftpdir.$file)){unlink($ftpdir.$file);} 
         } 
       } 


     } 

closedir($handle); 

답변

0

입니다 얻을.

  1. 퍼티는 어떻게 든 내 명시 적으로 "사용 UTF-8"설정
  2. 난에 "comments_html"잘못된 ID3 태그를 복사되지 않은 사용 된 클래스를 무시했다. 내가 print_r-ed 결과를 얻었을 때 실제 태그에 액세스하여 손상되지 않은 utf-8을 얻을 수 있음을 알게되었습니다.
관련 문제