I have a txt file where, if I open a standard text editor like notepad or scite, I can read lines like this:
Artist1 β Title 1 Artist2 β Title 2
Than I open it with a PHP script, and I read the lines:
$tracklistFile_name=time().rand(1, 1000).".".pathinfo($_FILES['tracklistFile']['name'], PATHINFO_EXTENSION); if(((pathinfo($tracklistFile_name, PATHINFO_EXTENSION)=='txt')) && (move_uploaded_file($_FILES['tracklistFile']['tmp_name'], 'import/'.$tracklistFile_name))) { $fileArray=file('import/'.$tracklistFile_name, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $fileArray=array_values(array_filter($fileArray, "trim")); for($i=0; $i<sizeof($fileArray); $i++) { echo $fileArray[$i]."<br />"; } }
and ... WOW ... I get this result:
Artist1 Title1 Artist2 Title2
??? What is this symbol? I think the encoding is failing. The symbol is so mistaken that I cannot insert them into the database, nor using mysql_real_escape_string() . In fact, I get this error when I try to insert them:
Incorrect string value: '\x96 Titl...' for column 'atl' at row 1
How can I solve this problem? Suggestions?
EDIT
Tried to add utf8_encode () before pasting / adding these lines: now pasting is not a failure, but the result is:
Artist1 Title1 Artist2 Title2
So, I lost the information. Why?