Task #306 - The myltibyte string library: Final corrections in the functions api_htmlentities() and api_html_entity_decode().

skala
Ivan Tcholakov 16 years ago
parent d622e4b58a
commit 7d07b31a40
  1. 11
      main/inc/lib/multibyte_string_functions.lib.php

@ -244,7 +244,7 @@ function api_htmlentities($string, $quote_style = ENT_COMPAT, $encoding = null)
} }
switch($quote_style) { switch($quote_style) {
case ENT_COMPAT: case ENT_COMPAT:
$string = str_replace('\'', '"', $string); $string = str_replace('"', '"', $string);
break; break;
case ENT_QUOTES: case ENT_QUOTES:
$string = str_replace(array('\'', '"'), array(''', '"'), $string); $string = str_replace(array('\'', '"'), array(''', '"'), $string);
@ -266,14 +266,14 @@ function api_html_entity_decode($string, $quote_style = ENT_COMPAT, $encoding =
if (empty($encoding)) { if (empty($encoding)) {
$encoding = api_mb_internal_encoding(); $encoding = api_mb_internal_encoding();
} }
if (!api_is_utf8($encoding) && api_html_entity_supports($encoding)) { if (api_html_entity_supports($encoding)) {
return html_entity_decode($string, $quote_style, $encoding); return html_entity_decode($string, $quote_style, $encoding);
} }
if (!api_is_encoding_supported($encoding)) { if (api_is_encoding_supported($encoding)) {
return $string;
}
return api_utf8_decode(html_entity_decode(api_convert_encoding($string, 'UTF-8', $encoding), $quote_style, 'UTF-8'), $encoding); return api_utf8_decode(html_entity_decode(api_convert_encoding($string, 'UTF-8', $encoding), $quote_style, 'UTF-8'), $encoding);
} }
return $string;
}
/** /**
* This function encodes (conditionally) a given string to UTF-8 if XmlHttp-request has been detected. * This function encodes (conditionally) a given string to UTF-8 if XmlHttp-request has been detected.
@ -336,7 +336,6 @@ function api_file_system_decode($string, $to_encoding = null) {
* If $search is an array and $replace is a string, then this replacement string is used for every value of search. * If $search is an array and $replace is a string, then this replacement string is used for every value of search.
* This function is aimed at replacing the function str_ireplace() for human-language strings. * This function is aimed at replacing the function str_ireplace() for human-language strings.
* @link http://php.net/manual/en/function.str-ireplace * @link http://php.net/manual/en/function.str-ireplace
* TODO: To be revised and to be checked.
*/ */
function api_str_ireplace($search, $replace, $subject, & $count = null, $encoding = null) { function api_str_ireplace($search, $replace, $subject, & $count = null, $encoding = null) {
if (empty($encoding)) { if (empty($encoding)) {

Loading…
Cancel
Save