X-Git-Url: https://jasonwoof.com/gitweb/?p=wfpl.git;a=blobdiff_plain;f=encode.php;h=a395a10ef3e8558dc23b7a11214e811741b7d89d;hp=e8d3d357efae4b2a5b0da1ed07cc9e0a3f325cde;hb=HEAD;hpb=22989a9ee35a199c5ef75ace19244761ea8c5af6 diff --git a/encode.php b/encode.php index e8d3d35..a395a10 100644 --- a/encode.php +++ b/encode.php @@ -1,19 +1,9 @@ . +# This program is in the public domain within the United States. Additionally, +# we waive copyright and related rights in the work worldwide through the CC0 +# 1.0 Universal public domain dedication, which can be found at +# http://creativecommons.org/publicdomain/zero/1.0/ # This file contains basic encodings. These are used by the encoder. You can @@ -42,6 +32,10 @@ function enc_jsdq($str) { return $str; } +function enc_json($str) { + return json_encode($str); +} + # encode for putting within double-quotes in SQL function enc_sql($str) { $str = str_replace("\\", "\\\\", $str); @@ -74,7 +68,7 @@ function enc_htmlbr($str) { # Example:

~foo htmlbrtab~

function enc_htmlbrtab($str) { $str = enc_htmlbr($str); - $whitespace_to_nbsp = create_function('$matches', '$count = 0; $chars = str_split($matches[0]); foreach ($chars as $c) { if ($c == " ") { $count += 2; } else if ($c == "\t") { $count += 8; } } return str_repeat(" ", $count);'); + $whitespace_to_nbsp = create_function('$matches', '$count = 0; $chars = str_split($matches[0]); foreach ($chars as $c) { if ($c == " ") { $count += 1; } else if ($c == "\t") { $count += 8; } } return str_repeat(" ", $count);'); $str = preg_replace_callback("|^[ \t]+|m", $whitespace_to_nbsp, $str); return $str; } @@ -379,10 +373,10 @@ function encode_options($selected, $options) { $out = ''; foreach($options as $option) { - list($value, $display, $arg3) = $option; + list($value, $display) = $option; $out .= '