cvs: peardoc /scripts fr_accent2htmlentities.php
| From: | Yannick Torres | Date: | Thu, 16 Feb 2006 16:35:24 +0000 |
| Subject: | cvs: peardoc /scripts fr_accent2htmlentities.php | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-7536@lists.php.net to get a copy of this message | ||
yannick Thu Feb 16 16:35:24 2006 UTC
Added files:
/peardoc/scripts fr_accent2htmlentities.php
Log:
Simple script to convert french's accents to there html's entities for Peardoc.
http://cvs.php.net/viewcvs.cgi/peardoc/scripts/fr_accent2htmlentities.php?view=markup&rev=1.1
Index: peardoc/scripts/fr_accent2htmlentities.php
+++ peardoc/scripts/fr_accent2htmlentities.php
#!/usr/bin/php -q
<?php
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2006 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.txt.
|
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Yannick Torrès <yannick@php.net> |
+----------------------------------------------------------------------+
*/
if ( $argc != 2 ) {
?>
Simple script to convert french's accents to there html's entities for Peardoc.
Usage:
<?php echo $argv[0]; ?> <path to file>
<path to file> must be a valid path.
Author: Yannick Torrès <yannick@php.net>
<?php
exit;
}
$file = $argv[1];
// File must be valid
if( !is_file($file) ) {
echo 'Error : Specified file is not valid'."\n";
exit;
}
if( !is_writable($file) ) {
echo 'Error : File is not writable'."\n";
exit;
}
// Get content of this file
$file_content = file_get_contents($file);
// Accents to htmlentities
$accent = array(
'à'=>'à',
'À'=>'À',
'â'=>'â',
'ä'=>'ä',
'é'=>'é',
'è'=>'è',
'É'=>'É',
'È'=>'È',
'ê'=>'ê',
'ë'=>'ë',
'î'=>'î',
'ï'=>'ï',
'ô'=>'ô',
'ö'=>'ö',
'ù'=>'ù',
'û'=>'û',
'ü'=>'ü',
'ç'=>'ç',
'Ç'=>'Ç'
);
while( list($key, $val) = each($accent) ) {
$file_content = str_replace($key, $val, $file_content);
}
if (!$handle = fopen($file, 'w')) {
echo 'Error : Cannot open file'."\n";
exit;
}
// Write content to our opened file.
if (fwrite($handle, $file_content) === FALSE) {
echo 'Error : Cannot write to file'."\n";
exit;
}
echo "Success !\n";
fclose($handle);
?>