PageRenderTime 23ms CodeModel.GetById 14ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/libraries/vendor/joomla/string/src/phputf8/utf8.php

https://gitlab.com/vitaliylukin91/idea-rating
PHP | 74 lines | 24 code | 7 blank | 43 comment | 8 complexity | cd88682ddce48e6d186288fa82925a8a MD5 | raw file
 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*/
26if ( !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*/
37if ( 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* Check whether PCRE has been compiled with UTF-8 support
46*/
47$UTF8_ar = array();
48if ( preg_match('/^.{1}$/u',"ñ",$UTF8_ar) != 1 ) {
49    trigger_error('PCRE is not compiled with UTF-8 support',E_USER_ERROR);
50}
51unset($UTF8_ar);
52
53
54/**
55* Load the smartest implementations of utf8_strpos, utf8_strrpos
56* and utf8_substr
57*/
58if ( !defined('UTF8_CORE') ) {
59    if ( function_exists('mb_substr') ) {
60        require_once UTF8 . '/mbstring/core.php';
61    } else {
62        require_once UTF8 . '/utils/unicode.php';
63        require_once UTF8 . '/native/core.php';
64    }
65}
66
67/**
68* Load the native implementation of utf8_substr_replace
69*/
70require_once UTF8 . '/substr_replace.php';
71
72/**
73* You should now be able to use all the other utf_* string functions
74*/