Voila j'ai réussi à le faire pour le ISO et l'HTML... avec affichage des codes sources...
voici les codes... il reste juste un truc d'un peu génant, c'est que le code source fait un peu le rebelle et sort de la page... mais bon c'est une détail...
------------------------index.php :-----------------------------
<!--by www.cyrilguerin.fr-->
<form action="trad.php" method="post">
<p>
<table>
<tr><td><label for="choix">Coder en : </label></td>
<td>ISO<INPUT type=radio name="choix" value="iso" checked="checked">
<br>HTML<INPUT type=radio name="choix" value="html">
<br>Les deux<INPUT type=radio name="choix" value="lesdeux"></td></tr>
</table>
</p>
<p>
<label for="texte">texte à coder :<br></label>
<textarea name="texte" rows="20" cols="60"></textarea>
</p>
<p>
<input type="reset" name="reset" value="Effacer" />
<input type="submit" name="send" value="Envoyer" />
</p>
</form>
---------------------------------------trad.php :-------------------------------------
<?php
/*by www.cyrilguerin.fr*/
$choix=$_POST['choix'];
$texte=$_POST['texte'];
function writeTextFile($fileName,$text) {
$session = fopen($fileName,"a+");
fputs($session,$text);
fclose($session);
}
if ($choix == 'iso'){
$texte = preg_replace('#\à#', 'à', $texte);
$texte = preg_replace('#\ç#', 'ç', $texte);
$texte = preg_replace('#\è#', 'è', $texte);
$texte = preg_replace('#\é#', 'é', $texte);
$texte = preg_replace('#\ê#', 'ê', $texte);
$texte = preg_replace('#\ô#', 'ô', $texte);
$texte = preg_replace('#\ù#', 'ù', $texte);
$texte = preg_replace('#\!#', '!', $texte);
$texte = preg_replace('#\"#', '"', $texte);
$texte = preg_replace('#\'#', ''', $texte);
$texte = preg_replace('#\<#', '<', $texte);
$texte = preg_replace('#\@#', '@', $texte);
$texte = preg_replace('#\€#', '€', $texte);
$texte = preg_replace('#\©#', '©', $texte);
echo "<u>Texte de base :</u><br><br>";
echo $texte;
echo "<br><br>";
ob_start();
$content = ob_get_contents();
writeTextFile("texteiso.php",$texte);
echo "<u>Texte codé en ISO :</u><br><br>";
highlight_file('texteiso.php');
}
else if($choix == 'html'){
$texte = preg_replace('#\<b\>(.+)\</b\>#i', '<strong>$1</strong>', $texte);
$texte = preg_replace('#\à#', 'à', $texte);
$texte = preg_replace('#\ç#', 'ç', $texte);
$texte = preg_replace('#\è#', 'è', $texte);
$texte = preg_replace('#\é#', 'é', $texte);
$texte = preg_replace('#\ê#', 'ê', $texte);
$texte = preg_replace('#\ô#', 'ô', $texte);
$texte = preg_replace('#\ù#', 'ù', $texte);
$texte = preg_replace('#\"#', '"', $texte);
$texte = preg_replace('#\<#', '<', $texte);
$texte = preg_replace('#\€#', '€', $texte);
$texte = preg_replace('#\©#', '©', $texte);
echo "<u>Texte de base :</u><br><br>";
echo $texte;
echo "<br><br>";
ob_start();
$content = ob_get_contents();
writeTextFile("textehtml.php",$texte);
echo "<u>Texte codé en HTML : </u><br><br>";
highlight_file('textehtml.php');
}
else if($choix == 'lesdeux'){
$textehtml = $texte;
$texteiso = $texte;
$textehtml = preg_replace('#\<b\>(.+)\</b\>#i', '<strong>$1</strong>', $textehtml);
$textehtml = preg_replace('#\à#', 'à', $textehtml);
$textehtml = preg_replace('#\ç#', 'ç', $textehtml);
$textehtml = preg_replace('#\è#', 'è', $textehtml);
$textehtml = preg_replace('#\é#', 'é', $textehtml);
$textehtml = preg_replace('#\ê#', 'ê', $textehtml);
$textehtml = preg_replace('#\ô#', 'ô', $textehtml);
$textehtml = preg_replace('#\ù#', 'ù', $textehtml);
$textehtml = preg_replace('#\"#', '"', $textehtml);
$textehtml = preg_replace('#\<#', '<', $textehtml);
$textehtml = preg_replace('#\€#', '€', $textehtml);
$textehtml = preg_replace('#\©#', '©', $textehtml);
echo "<u>Texte de base :</u><br><br>";
echo $textehtml;
echo "<br><br>";
ob_start();
$content = ob_get_contents();
writeTextFile("textehtml.php",$textehtml);
echo "<u>Texte codé en HTML</u> : <br><br>";
highlight_file('textehtml.php');
$texteiso = preg_replace('#\à#', 'à', $texteiso);
$texteiso = preg_replace('#\ç#', 'ç', $texteiso);
$texteiso = preg_replace('#\è#', 'è', $texteiso);
$texteiso = preg_replace('#\é#', 'é', $texteiso);
$texteiso = preg_replace('#\ê#', 'ê', $texteiso);
$texteiso = preg_replace('#\ô#', 'ô', $texteiso);
$texteiso = preg_replace('#\ù#', 'ù', $texteiso);
$texteiso = preg_replace('#\!#', '!', $texteiso);
$texteiso = preg_replace('#\"#', '"', $texteiso);
$texteiso = preg_replace('#\'#', ''', $texteiso);
$texteiso = preg_replace('#\<#', '<', $texteiso);
$texteiso = preg_replace('#\@#', '@', $texteiso);
$texteiso = preg_replace('#\€#', '€', $texteiso);
$texteiso = preg_replace('#\©#', '©', $texteiso);
echo "<br><br>";
ob_start();
$content = ob_get_contents();
writeTextFile("texteiso.php",$texteiso);
echo "<u>Texte codé en ISO :</u><br><br>";
highlight_file('texteiso.php');
}
?>
<br>
<a href="index.php"><br>Traduire un autre texte</a>
<?php if (file_exists("texteiso.php")){unlink("texteiso.php");}
if (file_exists("textehtml.php")){unlink("textehtml.php");}?>