Bonjour à tous,
Cela fait quelques jours que je bataille avec le codage des caractères en PHP et voici ma problématique :
J'ai un script ci-dessous qui à pour but d'enregistrer un fichier image (.jpg) avec un nom comprenant des caractères Grecques.
Aucun des fichiers créés pour le test n'a le nom que je lui demande une fois enregistré sur le disque du serveur.
Je ne sais plus par quel bout prendre ce problème. Windows n'est pas le système idéal pour l'utilisation de chaines de caractère en langue étrangère et je pourrai me tourner vers un serveur PHP LINUX / Apache (Unicode) mais j'aimerai comprendre ou est mon erreur dans ce code.
Merci d'avance à celui qui pourra me dépanner.
Stéphane
Note : Le serveur est Windows IIs (FastCGI PHP 5.4.24)
Windows NT LBS 6.2 build 9200 (Unknown Windows version Standard Edition) i586
Réglages PHP.ini
iconv :
mbstring :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 iconv support enabled iconv implementation "libiconv" iconv library version 1.14 Directive Local Value Master Value iconv.input_encoding UTF-8 UTF-8 iconv.internal_encoding UTF-8 UTF-8 iconv.output_encoding UTF-8 UTF-8
Voici le script PHP en question :
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 Multibyte Support enabled Multibyte string engine libmbfl HTTP input encoding translation enabled libmbfl version 1.3.2 mbstring extension makes use of "streamable kanji code filter and converter", which is distributed under the GNU Lesser General Public License version 2.1. Multibyte (japanese) regex support enabled Multibyte regex (oniguruma) version 4.7.1 Directive Local Value Master Value mbstring.detect_order no value no value mbstring.encoding_translation On On mbstring.func_overload 0 0 mbstring.http_input auto auto mbstring.http_output auto auto mbstring.http_output_conv_mimetypes ^(text/|application/xhtml\+xml) ^(text/|application/xhtml\+xml) mbstring.internal_encoding no value no value mbstring.language neutral neutral mbstring.strict_detection Off Off mbstring.substitute_character no value no value
Code php : 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
22
23
24
25
26
27
28
29
30
31 header( 'content-type: text/html; charset=utf-8' ); $tab = array("UTF-8", "ASCII", "Windows-1252", "Windows-2312", "Windows-28597","Windows-874", "Windows-932", "Windows-936", "Windows-949", "Windows-950", "Windows-1200", "Windows-1201", "Windows-1250", "Windows-1251", "Windows-1252", "Windows-1253", "Windows-1254", "Windows-1255", "Windows-1256", "Windows-1257", "Windows-1258", "Windows-6500", "Windows-6501", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", "ISO-8859-4", "ISO-8859-5", "ISO-8859-6","ISO-8859-7","ISO-8859-8","ISO-8859-9","ISO-8859-10","ISO-8859-11","ISO-8859-12","ISO-8859-13","ISO-8859-14","ISO-8859-15", "CP1256", "CP936", "CP2312", "CP28597", "CP932", "gb2312", "GB2312", "shift_jis", "GB18030", "ibm869", "big5", "utf-32", "utf-32BE", "x-cp20936", "x-cp50227"); $chain = ""; foreach ($tab as $i) { foreach ($tab as $j) { //Avec mb_convert_encoding //setlocale(LC_ALL, "ell" , "greek"); $chain = " $i vers $j "." ".mb_convert_encoding("Λίπη", $i, $j); //Chinois simplifié //$chain = " $i vers $j "." ".mb_convert_encoding("谷", $i, $j); copy($targetFile, $targetPath . stripslashes($chain.".jpg")); //Avec Iconv //Grecque $chain = " $i vers $j "." ".iconv($i, $j."//TRANSLIT", "Λίπη"); copy($targetFile, $targetPath . stripslashes($chain." inconvTest.jpg")); } }
Partager