PHP 클래스 lithium\g11n\Multibyte

Over time - as the importance of multibyte encoding support grew - a variety of extensions appeared. While each achieves its goal somewhat differently and might be preferred over the other, they still all do that one thing. What can a framework provide, those extensions aren't? It can provide abstractions that allow portable code. While this might not be a requirement for application code, it's a definite must for the framework's core code. As previously mentioned extensions appeared in a semi-evolutionary way. This leaves us with the situation where extensions are heterogeneously spread out over environments. There certainly is no clear winner and we're left with the situation of "supporting them all". Technically this class does very little in terms of abstraction. Its main purpose is to allow adapting to changing environments: virtually creating something you can rely on, something that's always there while it actually is there only in one way or the other. And - yes - some convenience methods are also on board.
상속: extends lithium\core\Adaptable
파일 보기 프로젝트 열기: unionofrad/lithium 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_adapters Libraries::locate()-compatible path to adapters for this class.
$_configurations array Contains adapter configurations for Multibyte adapters.

공개 메소드들

메소드 설명
is ( string $string, array $options = [] ) : boolean Checks if a given string is UTF-8 encoded and is valid UTF-8.
strlen ( string $string, array $options = [] ) : integer Gets the string length. Multibyte enabled version of strlen().
strpos ( string $haystack, string $needle, integer $offset, array $options = [] ) : integer Finds the position of the _first_ occurrence of a string within a string.
strrpos ( string $haystack, string $needle, array $options = [] ) : integer Finds the position of the _last_ occurrence of a string within a string.
substr ( string $string, integer $start, integer $length = null, array $options = [] ) : string Returns the portion of string specified by the start and length parameters.

메소드 상세

is() 공개 정적인 메소드

In _quick_ mode it will check only for non ASCII characters being used indicating any multibyte encoding. Don't use quick mode for integrity validation of UTF-8 encoded strings. Meaning of RegExp: '[\x09\x0A\x0D\x20-\x7E]'; // ASCII '|[\xC2-\xDF][\x80-\xBF]'; // non-overlong 2-byte '|\xE0[\xA0-\xBF][\x80-\xBF]'; // excluding overlongs '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}'; // straight 3-byte '|\xED[\x80-\x9F][\x80-\xBF]'; // excluding surrogates '|\xF0[\x90-\xBF][\x80-\xBF]{2}'; // planes 1-3 '|[\xF1-\xF3][\x80-\xBF]{3}'; // planes 4-15 '|\xF4[\x80-\x8F][\x80-\xBF]{2}'; // plane 16
public static is ( string $string, array $options = [] ) : boolean
$string string The string to analyze.
$options array Allows to toggle mode via the `'quick'` option, defaults to `false`.
리턴 boolean Returns `true` if the string is UTF-8.

strlen() 공개 정적인 메소드

Gets the string length. Multibyte enabled version of strlen().
public static strlen ( string $string, array $options = [] ) : integer
$string string The string being measured for length.
$options array Allows for selecting the adapter to use via the `name` options. Will use the `'default'` adapter by default.
리턴 integer The length of the string on success.

strpos() 공개 정적인 메소드

Multibyte enabled version of strpos(). Not all adapters must support interpreting - thus applying - passed numeric values as ordinal values of a character.
public static strpos ( string $haystack, string $needle, integer $offset, array $options = [] ) : integer
$haystack string The string being checked.
$needle string The string to find in the haystack.
$offset integer If specified, search will start this number of characters counted from the beginning of the string. The offset cannot be negative.
$options array Allows for selecting the adapter to use via the `name` options. Will use the `'default'` adapter by default.
리턴 integer Returns the numeric position of the first occurrence of the needle in the haystack string. If needle is not found, it returns `false`.

strrpos() 공개 정적인 메소드

Multibyte enabled version of strrpos(). Not all adapters must support interpreting - thus applying - passed numeric values as ordinal values of a character. The Iconv adapter doesn't support an offset as strpos() does - this constitutes the lowest common denominator here.
public static strrpos ( string $haystack, string $needle, array $options = [] ) : integer
$haystack string The string being checked.
$needle string The string to find in the haystack.
$options array Allows for selecting the adapter to use via the `name` options. Will use the `'default'` adapter by default.
리턴 integer Returns the numeric position of the last occurrence of the needle in the haystack string. If needle is not found, it returns `false`.

substr() 공개 정적인 메소드

Multibyte enabled version of substr().
public static substr ( string $string, integer $start, integer $length = null, array $options = [] ) : string
$string string The string to extract the substring from.
$start integer Position of first character in string (offset).
$length integer Maximum numbers of characters to use from string.
$options array Allows for selecting the adapter to use via the `name` options. Will use the `'default'` adapter by default.
리턴 string The substring extracted from given string.

프로퍼티 상세

$_adapters 보호되어 있는 정적으로 프로퍼티

Libraries::locate()-compatible path to adapters for this class.
또한 보기: lithium\core\Libraries::locate()
protected static $_adapters

$_configurations 보호되어 있는 정적으로 프로퍼티

Contains adapter configurations for Multibyte adapters.
protected static array $_configurations
리턴 array