note 30116 deleted from ref.strings by tomsommer
| From: | tomsommer@php.net | Date: | Wed, 15 Sep 2004 20:48:11 +0000 |
| Subject: | note 30116 deleted from ref.strings by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-76790@lists.php.net to get a copy of this message | ||
Note Submitter: kop at meme dot com
----
function standardize_eol($s) {
/* Return text with Unix end of line conventions.
*
* Input: $s The string to convert.
*
* Returns: The string with Unix end of line conventions.
*
* Side Effects: none
*/
return strtr(ereg_replace("\r\n", "\n", $s), "\r", "\n");
}
To do the same thing to a file:
// Copy file, converting
// Windoze and mac eol sequences to Unix eol along the way.
exec("sed -e 's/\r\$//' $old_path"
. ' | tr "\\r" "\\n"'
. " > $new_path");
Do _not_ try to set $old_path and $new_path to the same file. Failure will be erratic.