コード例 #1
0
ファイル: trim.php プロジェクト: azuya/Wi3
/**
 * UTF8::trim
 *
 * @package    Kohana
 * @author     Kohana Team
 * @copyright  (c) 2007-2010 Kohana Team
 * @copyright  (c) 2005 Harry Fuecks
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
 */
function _trim($str, $charlist = NULL)
{
    if ($charlist === NULL) {
        return trim($str);
    }
    return UTF8::ltrim(UTF8::rtrim($str, $charlist), $charlist);
}
コード例 #2
0
ファイル: UTF8Test.php プロジェクト: azuya/Wi3
 /**
  * Tests UTF8::rtrim
  *
  * @test
  * @dataProvider provider_rtrim
  */
 public function test_rtrim($input, $input2, $expected)
 {
     $this->assertSame($expected, UTF8::rtrim($input, $input2));
 }
コード例 #3
0
ファイル: utf8.class.php プロジェクト: xiaodin1/myqee
 /**
  * Strips whitespace (or other UTF-8 characters) from the beginning and
  * end of a string. This is a UTF8-aware version of [trim](http://php.net/trim).
  *
  * $str = UTF8::trim($str);
  *
  * @author  Andreas Gohr <*****@*****.**>
  * @param   string   input string
  * @param   string   string of characters to remove
  * @return  string
  */
 public static function trim($str, $charlist = null)
 {
     if ($charlist === null) {
         return trim($str);
     }
     return UTF8::ltrim(UTF8::rtrim($str, $charlist), $charlist);
 }
コード例 #4
0
ファイル: UTF8.php プロジェクト: gnribeiro/turim
 /**
  * Strips whitespace (or other UTF-8 characters) from the beginning and
  * end of a string. This is a UTF8-aware version of [trim](http://php.net/trim).
  *
  *     $str = UTF8::wptrim($str);
  *
  * @author  Andreas Gohr <*****@*****.**>
  * @param   string  $str        input string
  * @param   string  $charlist   string of characters to remove
  * @return  string
  */
 public static function trim($str, $charlist = NULL)
 {
     if ($charlist === NULL) {
         return trim($str);
     }
     return UTF8::wpltrim(UTF8::rtrim($str, $charlist), $charlist);
 }
コード例 #5
0
 /**
  * Word Limiter, UTF-8 version.
  *
  * Limits a string to X number of words.
  *
  * @param       string
  * @param       int
  * @param       string    The end character. Usually an ellipsis
  * @return      string
  */
 function word_limiter($str, $limit = 100, $end_char = '&#8230;')
 {
     if (UTF8::trim($str) === '') {
         return $str;
     }
     // Added by Ivan Tcholakov, 08-FEB-2016.
     $end_char = html_entity_decode($end_char, ENT_QUOTES, 'UTF-8');
     //
     preg_match('/^\\s*+(?:\\S++\\s*+){1,' . (int) $limit . '}/' . (IS_UTF8_CHARSET && PCRE_UTF8_INSTALLED ? 'u' : ''), $str, $matches);
     if (UTF8::strlen($str) === UTF8::strlen($matches[0])) {
         $end_char = '';
     }
     return UTF8::rtrim($matches[0]) . $end_char;
 }
コード例 #6
0
 /**
  * Word Limiter, UTF-8 version.
  *
  * Limits a string to X number of words.
  *
  * @param       string
  * @param       int
  * @param       string    The end character. Usually an ellipsis
  * @return      string
  */
 function word_limiter($str, $limit = 100, $end_char = '&#8230;')
 {
     if (UTF8::trim($str) === '') {
         return $str;
     }
     preg_match('/^\\s*+(?:\\S++\\s*+){1,' . (int) $limit . '}/' . (IS_UTF8_CHARSET && PCRE_UTF8_INSTALLED ? 'u' : ''), $str, $matches);
     if (UTF8::strlen($str) === UTF8::strlen($matches[0])) {
         $end_char = '';
     }
     return UTF8::rtrim($matches[0]) . $end_char;
 }