27 static $_double_encode = null;
28 if ($_double_encode === null) {
29 $_double_encode = version_compare(PHP_VERSION,
'5.2.3',
'>=');
38 if ($_double_encode) {
40 return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
44 return htmlspecialchars($string, ENT_QUOTES, $char_set);
47 $string = preg_replace(
'!&(#?\w+);!',
'%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
48 $string = htmlspecialchars($string, ENT_QUOTES, $char_set);
49 $string = str_replace(array(
'%%%SMARTY_START%%%',
'%%%SMARTY_END%%%'), array(
'&',
';'), $string);
58 if ($_double_encode) {
60 $string = htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
64 $string = htmlspecialchars($string, ENT_QUOTES, $char_set);
67 $string = preg_replace(
'!&(#?\w+);!',
'%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
68 $string = htmlspecialchars($string, ENT_QUOTES, $char_set);
69 $string = str_replace(array(
'%%%SMARTY_START%%%',
'%%%SMARTY_END%%%'), array(
'&',
';'), $string);
76 return mb_convert_encoding($string,
'HTML-ENTITIES', $char_set);
80 if ($_double_encode) {
81 return htmlentities($string, ENT_QUOTES, $char_set, $double_encode);
84 return htmlentities($string, ENT_QUOTES, $char_set);
86 $string = preg_replace(
'!&(#?\w+);!',
'%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
87 $string = htmlentities($string, ENT_QUOTES, $char_set);
88 $string = str_replace(array(
'%%%SMARTY_START%%%',
'%%%SMARTY_END%%%'), array(
'&',
';'), $string);
95 return rawurlencode($string);
98 return str_replace(
'%2F',
'/', rawurlencode($string));
102 return preg_replace(
"%(?<!\\\\)'%",
"\\'", $string);
108 $_length = strlen($string);
109 for ($x = 0; $x < $_length; $x ++) {
110 $return .=
'%' . bin2hex($string[$x]);
118 require_once(SMARTY_PLUGINS_DIR .
'shared.mb_unicode.php');
121 $return .=
'&#x' . strtoupper(dechex($unicode)) .
';';
127 $_length = strlen($string);
128 for ($x = 0; $x < $_length; $x ++) {
129 $return .=
'&#x' . bin2hex($string[$x]) .
';';
137 require_once(SMARTY_PLUGINS_DIR .
'shared.mb_unicode.php');
140 $return .=
'&#' . $unicode .
';';
146 $_length = strlen($string);
147 for ($x = 0; $x < $_length; $x ++) {
148 $return .=
'&#' . ord($string[$x]) .
';';
155 return strtr($string, array(
'\\' =>
'\\\\',
"'" =>
"\\'",
'"' =>
'\\"',
"\r" =>
'\\r',
"\n" =>
'\\n',
'</' =>
'<\/'));
159 require_once(SMARTY_PLUGINS_DIR .
'shared.mb_str_replace.php');
161 return smarty_mb_str_replace(array(
'@',
'.'), array(
' [AT] ',
' [DOT] '), $string);
164 return str_replace(array(
'@',
'.'), array(
' [AT] ',
' [DOT] '), $string);
170 require_once(SMARTY_PLUGINS_DIR .
'shared.mb_unicode.php');
172 if ($unicode >= 126) {
173 $return .=
'&#' . $unicode .
';';
175 $return .= chr($unicode);
182 $_length = strlen($string);
183 for ($_i = 0; $_i < $_length; $_i ++) {
184 $_ord = ord(substr($string, $_i, 1));
187 $return .=
'&#' . $_ord .
';';
189 $return .= substr($string, $_i, 1);