cvs: peardoc /scripts fr_accent2htmlentities.php

From: 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( 'à'=>'&agrave;', 'À'=>'&Agrave;', 'â'=>'&acirc;', 'ä'=>'&auml;', 'é'=>'&eacute;', 'è'=>'&egrave;', 'É'=>'&Eacute;', 'È'=>'&Egrave;', 'ê'=>'&ecirc;', 'ë'=>'&euml;', 'î'=>'&icirc;', 'ï'=>'&iuml;', 'ô'=>'&ocirc;', 'ö'=>'&ouml;', 'ù'=>'&ugrave;', 'û'=>'&ucirc;', 'ü'=>'&uuml;', 'ç'=>'&ccedil;', 'Ç'=>'&Ccedil;' ); 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); ?>

« previous php.pear.doc (#7536) next »