Bonjour à tous,
J'importe dans un script PHP un fichier txt avec un encodage différent d'UTF-8, je change l'encodage et j'affiche le fichier texte dans une page web.
Ca fonction presque parfaitement, en effet le tout 1er caractères ne s'affiche pas correctement.
Pour avoir un exemple, exécutez ce bout de code :
Vous obtiendrez :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <head> <body> <?php $file = 'http://www.pandora-box.ovh.org/Windows/XP/exe/tous/str/accwiz_str.txt'; $tableau = file($file); while(list($cle, $val) = each($tableau)) { $ligne = mb_convert_encoding($val, "UTF-8", "UTF-16"); echo $ligne.'<br />'; } ?> </body> </html>
Q00 RestoreUI
2048 Restauration du système
...
Savez pourquoi ça fait ça ? Avez vous une solution ?
Merci d'avance
Partager