[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/libraries/phputf8/ -> utf8.php (source)

   1  <?php
   2  /**
   3  * This is the dynamic loader for the library. It checks whether you have
   4  * the mbstring extension available and includes relevant files
   5  * on that basis, falling back to the native (as in written in PHP) version
   6  * if mbstring is unavailabe.
   7  *
   8  * It's probably easiest to use this, if you don't want to understand
   9  * the dependencies involved, in conjunction with PHP versions etc. At
  10  * the same time, you might get better performance by managing loading
  11  * yourself. The smartest way to do this, bearing in mind performance,
  12  * is probably to "load on demand" - i.e. just before you use these
  13  * functions in your code, load the version you need.
  14  *
  15  * It makes sure the the following functions are available;
  16  * utf8_strlen, utf8_strpos, utf8_strrpos, utf8_substr,
  17  * utf8_strtolower, utf8_strtoupper
  18  * Other functions in the ./native directory depend on these
  19  * six functions being available
  20  * @package utf8
  21  */
  22  
  23  /**
  24  * Put the current directory in this constant
  25  */
  26  if ( !defined('UTF8') ) {
  27      define('UTF8',dirname(__FILE__));
  28  }
  29  
  30  /**
  31  * If string overloading is active, it will break many of the
  32  * native implementations. mbstring.func_overload must be set
  33  * to 0, 1 or 4 in php.ini (string overloading disabled).
  34  * Also need to check we have the correct internal mbstring
  35  * encoding
  36  */
  37  if ( extension_loaded('mbstring')) {
  38      if ( ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING ) {
  39          trigger_error('String functions are overloaded by mbstring',E_USER_ERROR);
  40      }
  41      mb_internal_encoding('UTF-8');
  42  }
  43  
  44  /**
  45  * Load the faster strlen if mbstring available
  46  */
  47  if ( !defined('UTF8_STRLEN') ) {
  48      if ( function_exists('mb_strlen') ) {
  49          mb_internal_encoding('UTF-8');
  50          require_once  UTF8 . '/mbstring/strlen.php';
  51      } else {
  52          require_once  UTF8 . '/native/strlen.php';
  53      }
  54  }
  55  
  56  /**
  57  * Load the smartest implementations of utf8_strpos, utf8_strrpos
  58  * and utf8_substr
  59  */
  60  if ( !defined('UTF8_CORE') ) {
  61      if ( function_exists('mb_substr') ) {
  62          require_once  UTF8 . '/mbstring/core.php';
  63      } else {
  64          require_once  UTF8 . '/native/core.php';
  65      }
  66  }
  67  
  68  /**
  69  * Load the smartest implementations of utf8_strtolower and
  70  * utf8_strtoupper
  71  */
  72  if ( !defined('UTF8_CASE') ) {
  73      if ( function_exists('mb_strtolower') ) {
  74          require_once  UTF8 . '/mbstring/case.php';
  75      } else {
  76          require_once  UTF8 . '/utils/unicode.php';
  77          require_once  UTF8 . '/native/case.php';
  78      }
  79  }
  80  
  81  /**
  82  * Load the native implementation of utf8_substr_replace
  83  */
  84  require_once  UTF8 . '/substr_replace.php';
  85  
  86  /**
  87  * You should now be able to use all the other utf_* string functions
  88  */


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1