UTF8
Kohana_UTF8

Class Contents

Class declared in SYSPATH/classes/utf8.php on line 3.

Properties

public static $called
array(0) 
public static $server_utf8
bool TRUE

Methods

public static clean( )
Kohana_UTF8

Source Code
public static function clean($var, $charset = NULL)
{
	if ( ! $charset)
	{
		// Use the application character set
		$charset = Kohana::$charset;
	}

	if (is_array($var) OR is_object($var))
	{
		foreach ($var as $key => $val)
		{
			// Recursion!
			$var[self::clean($key)] = self::clean($val);
		}
	}
	elseif (is_string($var) AND $var !== '')
	{
		// Remove control characters
		$var = self::strip_ascii_ctrl($var);

		if ( ! self::is_ascii($var))
		{
			// Disable notices
			$error_reporting = error_reporting(~E_NOTICE);

			// iconv is expensive, so it is only used when needed
			$var = iconv($charset, $charset.'//IGNORE', $var);

			// Turn notices back on
			error_reporting($error_reporting);
		}
	}

	return $var;
}

public static from_unicode( )
Kohana_UTF8

Source Code
public static function from_unicode($arr)
{
	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _from_unicode($arr);
}

public static is_ascii( )
Kohana_UTF8

Source Code
public static function is_ascii($str)
{
	if (is_array($str))
	{
		$str = implode($str);
	}

	return ! preg_match('/[^\x00-\x7F]/S', $str);
}

public static ltrim( )
Kohana_UTF8

Source Code
public static function ltrim($str, $charlist = NULL)
{
	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _ltrim($str, $charlist);
}

public static ord( )
Kohana_UTF8

Source Code
public static function ord($chr)
{
	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _ord($chr);
}

public static rtrim( )
Kohana_UTF8

Source Code
public static function rtrim($str, $charlist = NULL)
{
	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _rtrim($str, $charlist);
}

public static str_ireplace( )
Kohana_UTF8

Source Code
public static function str_ireplace($search, $replace, $str, & $count = NULL)
{
	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _str_ireplace($search, $replace, $str, $count);
}

public static str_pad( )
Kohana_UTF8

Source Code
public static function str_pad($str, $final_str_length, $pad_str = ' ', $pad_type = STR_PAD_RIGHT)
{
	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _str_pad($str, $final_str_length, $pad_str, $pad_type);
}

public static str_split( )
Kohana_UTF8

Source Code
public static function str_split($str, $split_length = 1)
{
	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _str_split($str, $split_length);
}

public static strcasecmp( )
Kohana_UTF8

Source Code
public static function strcasecmp($str1, $str2)
{
	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _strcasecmp($str1, $str2);
}

public static strcspn( )
Kohana_UTF8

Source Code
public static function strcspn($str, $mask, $offset = NULL, $length = NULL)
{
	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _strcspn($str, $mask, $offset, $length);
}

public static strip_ascii_ctrl( )
Kohana_UTF8

Source Code
public static function strip_ascii_ctrl($str)
{
	return preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S', '', $str);
}

public static strip_non_ascii( )
Kohana_UTF8

Source Code
public static function strip_non_ascii($str)
{
	return preg_replace('/[^\x00-\x7F]+/S', '', $str);
}

public static stristr( )
Kohana_UTF8

Source Code
public static function stristr($str, $search)
{
	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _stristr($str, $search);
}

public static strlen( )
Kohana_UTF8

Source Code
public static function strlen($str)
{
	if (UTF8::$server_utf8)
		return mb_strlen($str, Kohana::$charset);

	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _strlen($str);
}

public static strpos( )
Kohana_UTF8

Source Code
public static function strpos($str, $search, $offset = 0)
{
	if (UTF8::$server_utf8)
		return mb_strpos($str, $search, $offset, Kohana::$charset);

	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _strpos($str, $search, $offset);
}

public static strrev( )
Kohana_UTF8

Source Code
public static function strrev($str)
{
	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _strrev($str);
}

public static strrpos( )
Kohana_UTF8

Source Code
public static function strrpos($str, $search, $offset = 0)
{
	if (UTF8::$server_utf8)
		return mb_strrpos($str, $search, $offset, Kohana::$charset);

	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _strrpos($str, $search, $offset);
}

public static strspn( )
Kohana_UTF8

Source Code
public static function strspn($str, $mask, $offset = NULL, $length = NULL)
{
	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _strspn($str, $mask, $offset, $length);
}

public static strtolower( )
Kohana_UTF8

Source Code
public static function strtolower($str)
{
	if (UTF8::$server_utf8)
		return mb_strtolower($str, Kohana::$charset);

	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _strtolower($str);
}

public static strtoupper( )
Kohana_UTF8

Source Code
public static function strtoupper($str)
{
	if (UTF8::$server_utf8)
		return mb_strtoupper($str, Kohana::$charset);

	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _strtoupper($str);
}

public static substr( )
Kohana_UTF8

Source Code
public static function substr($str, $offset, $length = NULL)
{
	if (UTF8::$server_utf8)
		return ($length === NULL)
			? mb_substr($str, $offset, mb_strlen($str), Kohana::$charset)
			: mb_substr($str, $offset, $length, Kohana::$charset);

	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _substr($str, $offset, $length);
}

public static substr_replace( )
Kohana_UTF8

Source Code
public static function substr_replace($str, $replacement, $offset, $length = NULL)
{
	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _substr_replace($str, $replacement, $offset, $length);
}

public static to_unicode( )
Kohana_UTF8

Source Code
public static function to_unicode($str)
{
	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _to_unicode($str);
}

public static transliterate_to_ascii( )
Kohana_UTF8

Source Code
public static function transliterate_to_ascii($str, $case = 0)
{
	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _transliterate_to_ascii($str, $case);
}

public static trim( )
Kohana_UTF8

Source Code
public static function trim($str, $charlist = NULL)
{
	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _trim($str, $charlist);
}

public static ucfirst( )
Kohana_UTF8

Source Code
public static function ucfirst($str)
{
	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _ucfirst($str);
}

public static ucwords( )
Kohana_UTF8

Source Code
public static function ucwords($str)
{
	if ( ! isset(self::$called[__FUNCTION__]))
	{
		require SYSPATH.'utf8'.DIRECTORY_SEPARATOR.__FUNCTION__.EXT;

		// Function has been called
		self::$called[__FUNCTION__] = TRUE;
	}

	return _ucwords($str);
}