26 static $_double_encode = null;
27 if ($_double_encode === null) {
28 $_double_encode = version_compare(PHP_VERSION,
'5.2.3',
'>=');
37 if ($_double_encode) {
39 return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
43 return htmlspecialchars($string, ENT_QUOTES, $char_set);
46 $string = preg_replace(
'!&(#?\w+);!',
'%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
47 $string = htmlspecialchars($string, ENT_QUOTES, $char_set);
48 $string = str_replace(array(
'%%%SMARTY_START%%%',
'%%%SMARTY_END%%%'), array(
'&',
';'), $string);
56 if ($_double_encode) {
58 $string = htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
62 $string = htmlspecialchars($string, ENT_QUOTES, $char_set);
65 $string = preg_replace(
'!&(#?\w+);!',
'%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
66 $string = htmlspecialchars($string, ENT_QUOTES, $char_set);
67 $string = str_replace(array(
'%%%SMARTY_START%%%',
'%%%SMARTY_END%%%'), array(
'&',
';'), $string);
73 return mb_convert_encoding($string,
'HTML-ENTITIES', $char_set);
77 if ($_double_encode) {
78 return htmlentities($string, ENT_QUOTES, $char_set, $double_encode);
81 return htmlentities($string, ENT_QUOTES, $char_set);
83 $string = preg_replace(
'!&(#?\w+);!',
'%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
84 $string = htmlentities($string, ENT_QUOTES, $char_set);
85 $string = str_replace(array(
'%%%SMARTY_START%%%',
'%%%SMARTY_END%%%'), array(
'&',
';'), $string);
91 return rawurlencode($string);
94 return str_replace(
'%2F',
'/', rawurlencode($string));
98 return preg_replace(
"%(?<!\\\\)'%",
"\\'", $string);
104 $_length = strlen($string);
105 for ($x = 0; $x < $_length; $x++) {
106 $return .=
'%' . bin2hex($string[$x]);
113 require_once(SMARTY_PLUGINS_DIR .
'shared.mb_unicode.php');
116 $return .=
'&#x' . strtoupper(dechex($unicode)) .
';';
121 $_length = strlen($string);
122 for ($x = 0; $x < $_length; $x++) {
123 $return .=
'&#x' . bin2hex($string[$x]) .
';';
130 require_once(SMARTY_PLUGINS_DIR .
'shared.mb_unicode.php');
133 $return .=
'&#' . $unicode .
';';
138 $_length = strlen($string);
139 for ($x = 0; $x < $_length; $x++) {
140 $return .=
'&#' . ord($string[$x]) .
';';
146 return strtr($string, array(
'\\' =>
'\\\\',
"'" =>
"\\'",
'"' =>
'\\"',
"\r" =>
'\\r',
"\n" =>
'\\n',
'</' =>
'<\/'));
150 require_once(SMARTY_PLUGINS_DIR .
'shared.mb_str_replace.php');
151 return smarty_mb_str_replace(array(
'@',
'.'), array(
' [AT] ',
' [DOT] '), $string);
154 return str_replace(array(
'@',
'.'), array(
' [AT] ',
' [DOT] '), $string);
160 require_once(SMARTY_PLUGINS_DIR .
'shared.mb_unicode.php');
162 if ($unicode >= 126) {
163 $return .=
'&#' . $unicode .
';';
165 $return .= chr($unicode);
171 $_length = strlen($string);
172 for ($_i = 0; $_i < $_length; $_i++) {
173 $_ord = ord(substr($string, $_i, 1));
176 $return .=
'&#' . $_ord .
';';
178 $return .= substr($string, $_i, 1);
static $_MBSTRING
Flag denoting if Multibyte String functions are available.
smarty_modifier_escape($string, $esc_type= 'html', $char_set=null, $double_encode=true)
Smarty escape modifier plugin.
static $_CHARSET
The character set to adhere to (e.g.
smarty_mb_to_unicode($string, $encoding=null)
convert characters to their decimal unicode equivalents