/** * @param $value * @param $charlist * @param bool $utf8 * * @return null|string */ public static function trimAsNULL($value, $charlist = NULL, $utf8 = TRUE) { if (NULL !== $value) { if ($utf8) { $value = Kohana_UTF8::trim($value, $charlist); if (!Kohana_UTF8::strlen($value)) { $value = NULL; } } else { $value = trim($value, $charlist); if (!strlen($value)) { $value = NULL; } } } return $value; }
* Takes an array of ints representing the Unicode characters and returns a UTF-8 string. * Astral planes are supported i.e. the ints in the input can be > 0xFFFF. * Occurrances of the BOM are ignored. Surrogates are not allowed. * * $str = UTF8::to_unicode($array); * * The Original Code is Mozilla Communicator client code. * The Initial Developer of the Original Code is Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 the Initial Developer. * Ported to PHP by Henri Sivonen <*****@*****.**>, see http://hsivonen.iki.fi/php-utf8/ * Slight modifications to fit with phputf8 library by Harry Fuecks <*****@*****.**>. * * @param array unicode code points representing a string * @return string utf8 string of characters * @return boolean FALSE if a code point cannot be found */ 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); } } // End UTF8 if (Kohana_UTF8::$server_utf8 === NULL) { // Determine if this server supports UTF-8 natively Kohana_UTF8::$server_utf8 = extension_loaded('mbstring'); }