| | |
| | | function abbreviate_string($str, $maxlength, $place_holder='...') |
| | | { |
| | | $length = mb_strlen($str); |
| | | $first_part_length = floor($maxlength/2) - mb_strlen($place_holder); |
| | | |
| | | if ($length > $maxlength) |
| | | { |
| | | $second_starting_location = $length - $maxlength + $first_part_length + 1; |
| | | $str = mb_substr($str, 0, $first_part_length) . $place_holder . mb_substr($str, $second_starting_location, $length); |
| | | $place_holder_length = mb_strlen($place_holder); |
| | | $first_part_length = floor(($maxlength - $place_holder_length)/2); |
| | | $second_starting_location = $length - $maxlength + $first_part_length + $place_holder_length; |
| | | $str = mb_substr($str, 0, $first_part_length) . $place_holder . mb_substr($str, $second_starting_location); |
| | | } |
| | | |
| | | return $str; |
| | |
| | | if (function_exists('mb_convert_encoding') && ($res = mb_convert_encoding($input, 'UTF-8', 'UTF-8')) !== false) |
| | | return $res; |
| | | |
| | | if (function_exists('iconv') && ($res = iconv('UTF-8', 'UTF-8//IGNORE', $input)) !== false) |
| | | if (function_exists('iconv') && ($res = @iconv('UTF-8', 'UTF-8//IGNORE', $input)) !== false) |
| | | return $res; |
| | | |
| | | $regexp = '/^('. |
| | |
| | | { |
| | | $input = rc_utf8_clean($input); |
| | | |
| | | return json_encode($input); |
| | | // sometimes even using rc_utf8_clean() the input contains invalid UTF-8 sequences |
| | | // that's why we have @ here |
| | | return @json_encode($input); |
| | | } |
| | | |
| | | |