| | |
| | | { |
| | | if (is_numeric($str)) |
| | | return floatval($str); |
| | | |
| | | if (preg_match('/([0-9]+)([a-z])/i', $str, $regs)) |
| | | |
| | | if (preg_match('/([0-9\.]+)\s*([a-z]*)/i', $str, $regs)) |
| | | { |
| | | $bytes = floatval($regs[1]); |
| | | switch (strtolower($regs[2])) |
| | | { |
| | | case 'g': |
| | | case 'gb': |
| | | $bytes *= 1073741824; |
| | | break; |
| | | case 'm': |
| | | case 'mb': |
| | | $bytes *= 1048576; |
| | | break; |
| | | case 'k': |
| | | case 'kb': |
| | | $bytes *= 1024; |
| | | break; |
| | | } |
| | |
| | | return $input; |
| | | |
| | | // iconv/mbstring are much faster (especially with long strings) |
| | | if (function_exists('mb_convert_encoding') && ($res = mb_convert_encoding($input, 'UTF8', 'UTF8'))) |
| | | if (function_exists('mb_convert_encoding') && ($res = mb_convert_encoding($input, 'UTF-8', 'UTF-8')) !== false) |
| | | return $res; |
| | | |
| | | if (function_exists('iconv') && ($res = iconv('UTF8', 'UTF8//IGNORE', $input))) |
| | | if (function_exists('iconv') && ($res = @iconv('UTF-8', 'UTF-8//IGNORE', $input)) !== false) |
| | | return $res; |
| | | |
| | | $regexp = '/^('. |
| | |
| | | $seq = ''; |
| | | $out = ''; |
| | | |
| | | for ($i = 0, $len = strlen($input)-1; $i < $len; $i++) { |
| | | for ($i = 0, $len = strlen($input); $i < $len; $i++) { |
| | | $chr = $input[$i]; |
| | | $ord = ord($chr); |
| | | // 1-byte character |
| | |
| | | function json_serialize($input) |
| | | { |
| | | $input = rc_utf8_clean($input); |
| | | |
| | | |
| | | return json_encode($input); |
| | | } |
| | | |