From: Jason Woofenden Date: Tue, 9 Dec 2008 19:05:40 +0000 (-0500) Subject: added: enc_cap(), enc_htmlbrtab() X-Git-Url: https://jasonwoof.com/gitweb/?p=wfpl.git;a=commitdiff_plain;h=95c7851dae93bd7429a262158a4cd7e9b33d51f7 added: enc_cap(), enc_htmlbrtab() --- diff --git a/encode.php b/encode.php index db0cde3..11d60db 100644 --- a/encode.php +++ b/encode.php @@ -23,6 +23,10 @@ # will encode foo (using enc_html()) before displaying it, so that characters # such as < will display properly. +function enc_cap($str) { + $str = ucfirst($str); + return $str; +} function enc_jsdq($str) { $str = enc_sql($str); @@ -49,13 +53,24 @@ function enc_html($str) { # Encode for output in html. Convert newlines to
# -# Example:

~foo.html~

+# Example:

~foo.htmlbr~

function enc_htmlbr($str) { $str = enc_html($str); $str = str_replace("\n", "
\n", $str); return $str; } +# Encode for output in html. Preserves newlines and indentation by converting +# newlines to
and spaces at the begining of lines to    +# +# Example:

~foo.htmlbrtab~

+function enc_htmlbrtab($str) { + $str = enc_htmlbr($str); + $space_to_nbsp = create_function('$matches', 'return str_repeat(\' \', strlen($matches[0]) * 2);'); + $str = preg_replace_callback("|^ *|m", $space_to_nbsp, $str); + return $str; +} + # Encode for output in html. Spaces converted to   # # Example: