PHP Класс Habari\MultiByte

Provides multibyte character set services, a necessity since all of Habari's internal string manipulations are done in UTF-8. Currently this class is a wrapper around mbstring functions.
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$hab_enc String holding the current encoding the class is using

Открытые методы

Метод Описание
convert_encoding ( $str, $use_enc = null, $from_enc = null ) : mixed Converts a string's encoding to a new encoding
detect_bom_encoding ( $source_contents ) : mixed Detects the encoding being used for a string using the existence of a byte order mark
detect_encoding ( $str ) : mixed Detects the encoding being used for a string
hab_encoding ( $use_enc = null ) : string. Sets and returns the internal encoding.
lcfirst ( string $str, string $use_enc = null ) : string Makes a string's first character lowercase
library ( integer $new_library = null ) : mixed Sets and returns the multibyte library being used internally
str_ireplace ( mixed $search, mixed $replace, string $subject, integer &$count, string $use_enc = null ) : string Replace all occurrences of the search string with the replacement string.
str_replace ( mixed $search, mixed $replace, string $subject, integer &$count, string $use_enc = null ) : string Replace all occurrences of the search string with the replacement string.
stripos ( $haysack, $needle, $offset, $use_enc = null ) : mixed Find position of first occurrence of string in a string. Case insensitive.
strlen ( $str, $use_enc = null ) : integer. Gets the length of a string in characters
strpos ( $haysack, $needle, $offset, $use_enc = null ) : mixed Find position of first occurrence of string in a string
strripos ( $haysack, $needle, $offset, $use_enc = null ) : mixed Find position of last occurrence of string in a string. Case insensitive.
strrpos ( $haysack, $needle, $offset, $use_enc = null ) : mixed function strrpos
strtolower ( $str, $use_enc = null ) : string. function strtolower
strtoupper ( $str, $use_enc = null ) : string. Converts a multibyte string to uppercase. If a valid multibyte library isn't loaded, strtoupper() will be used, which can lead to unexpected results.
substr ( $str, $begin, $len = null, $use_enc = null ) : mixed Get a section of a string
ucfirst ( string $str, string $use_enc = null ) : string Makes a string's first character uppercase
ucwords ( string $str, string $use_enc = null ) : string Uppercase the first character of each word in a string.
valid_data ( string $str, null $use_enc = null ) : boolean Determines if the passed string is valid character data (according to mbstring)

Приватные методы

Метод Описание
__construct ( ) An empty constructor since all functions are static

Описание методов

convert_encoding() публичный статический Метод

Converts a string's encoding to a new encoding
public static convert_encoding ( $str, $use_enc = null, $from_enc = null ) : mixed
$str string. The string who's encoding is being changed.
$use_enc string. The encoding to convert to. If not set, the internal encoding will be used.
$from_enc string. encoding before conversion. If not set, encoding is detected automatically.
Результат mixed The source string in the new encoding or boolean false.

detect_bom_encoding() публичный статический Метод

Detects the encoding being used for a string using the existence of a byte order mark
public static detect_bom_encoding ( $source_contents ) : mixed
$source_contents string. The string whose encoding is being detected
Результат mixed The source string's detected encoding, or boolean false.

detect_encoding() публичный статический Метод

Detects the encoding being used for a string
public static detect_encoding ( $str ) : mixed
$str string. The string whose encoding is being detected
Результат mixed The source string's detected encoding, or boolean false.

hab_encoding() публичный статический Метод

Sets and returns the internal encoding.
public static hab_encoding ( $use_enc = null ) : string.
$use_enc string. The encoding to be used
Результат string.

lcfirst() публичный статический Метод

Makes a string's first character lowercase
См. также: http://php.net/ucfirst
public static lcfirst ( string $str, string $use_enc = null ) : string
$str string The string to lowercase.
$use_enc string The encoding to be used. If null, the internal encoding will be used.
Результат string The lowercased string.

library() публичный статический Метод

Sets and returns the multibyte library being used internally
public static library ( integer $new_library = null ) : mixed
$new_library integer The new library to use. One of the self::USE_* constants, null to simply return, or false to disable and use native non-multibyte-safe PHP methods.
Результат mixed If $new_library is null, returns the current library being used. If $new_library has a valid value, returns the old library, else returns false.

str_ireplace() публичный статический Метод

Replace all occurrences of the search string with the replacement string.
См. также: http://php.net/str_ireplace
public static str_ireplace ( mixed $search, mixed $replace, string $subject, integer &$count, string $use_enc = null ) : string
$search mixed A string or an array of strings to search for.
$replace mixed A string or an array of strings to replace search values with.
$subject string The string to perform the search and replace on.
$count integer If passed, this value will hold the number of matched and replaced needles.
$use_enc string The encoding to be used. If null, the internal encoding will be used.
Результат string The subject with replaced values.

str_replace() публичный статический Метод

Replace all occurrences of the search string with the replacement string.
См. также: http://php.net/str_replace
public static str_replace ( mixed $search, mixed $replace, string $subject, integer &$count, string $use_enc = null ) : string
$search mixed A string or an array of strings to search for.
$replace mixed A string or an array of strings to replace search values with.
$subject string The string to perform the search and replace on.
$count integer If passed, this value will hold the number of matched and replaced needles.
$use_enc string The encoding to be used. If null, the internal encoding will be used.
Результат string The subject with replaced values.

stripos() публичный статический Метод

Find position of first occurrence of string in a string. Case insensitive.
public static stripos ( $haysack, $needle, $offset, $use_enc = null ) : mixed
$haysack string. The string being checked.
$offset integer. The search offset. If it is not specified, 0 is used.
$use_enc string. The encoding to be used. If not set, the internal encoding will be used.
Результат mixed The section of the source string requested in the encoding requested or false. If $len is not set, returns substring from $begin to end of string.

strlen() публичный статический Метод

Gets the length of a string in characters
public static strlen ( $str, $use_enc = null ) : integer.
$str string. The string who's length is being returned.
$use_enc string. The encoding to be used. If not set, the internal encoding will be used.
Результат integer.

strpos() публичный статический Метод

Find position of first occurrence of string in a string
public static strpos ( $haysack, $needle, $offset, $use_enc = null ) : mixed
$haysack string. The string being checked.
$offset integer. The search offset. If it is not specified, 0 is used.
$use_enc string. The encoding to be used. If not set, the internal encoding will be used.
Результат mixed The section of the source string requested in the encoding requested or false. If $len is not set, returns substring from $begin to end of string.

strripos() публичный статический Метод

Find position of last occurrence of string in a string. Case insensitive.
public static strripos ( $haysack, $needle, $offset, $use_enc = null ) : mixed
$haysack string. The string being checked.
$offset integer. The search offset. If it is not specified, 0 is used.
$use_enc string. The encoding to be used. If not set, the internal encoding will be used.
Результат mixed The section of the source string requested in the encoding requested or false. If $len is not set, returns substring from $begin to end of string.

strrpos() публичный статический Метод

Find position of last occurrence of string in a string.
public static strrpos ( $haysack, $needle, $offset, $use_enc = null ) : mixed
$haysack string. The string being checked.
$offset integer. The search offset. If it is not specified, 0 is used.
$use_enc string. The encoding to be used. If not set, the internal encoding will be used.
Результат mixed The section of the source string requested in the encoding requested or false. If $len is not set, returns substring from $begin to end of string.

strtolower() публичный статический Метод

Converts a multibyte string to lowercase. If a valid multibyte library isn't loaded, strtolower() will be used, which can lead to unexpected results.
public static strtolower ( $str, $use_enc = null ) : string.
$str string. The string to lowercase
$use_enc string. The encoding to be used. If not set, the internal encoding will be used.
Результат string.

strtoupper() публичный статический Метод

Converts a multibyte string to uppercase. If a valid multibyte library isn't loaded, strtoupper() will be used, which can lead to unexpected results.
public static strtoupper ( $str, $use_enc = null ) : string.
$str string. The string to uppercase
$use_enc string. The encoding to be used. If not set, the internal encoding will be used.
Результат string.

substr() публичный статический Метод

Get a section of a string
public static substr ( $str, $begin, $len = null, $use_enc = null ) : mixed
$str string. The original string
$len integer. How long the returned string should be. If $len is not set, the section of the string from $begin to the end of the string is returned.
$use_enc string. The encoding to be used. If not set, the internal encoding will be used.
Результат mixed The section of the source string requested in the encoding requested or false. If $len is not set, returns substring from $begin to end of string.

ucfirst() публичный статический Метод

Makes a string's first character uppercase
См. также: http://php.net/ucfirst
public static ucfirst ( string $str, string $use_enc = null ) : string
$str string The string to capitalize.
$use_enc string The encoding to be used. If null, the internal encoding will be used.
Результат string The capitalized string.

ucwords() публичный статический Метод

From php.net/ucwords: The definition of a word is any string of characters that is immediately after a whitespace (These are: space, form-feed, newline, carriage return, horizontal tab, and vertical tab).
См. также: http://php.net/ucwords
public static ucwords ( string $str, string $use_enc = null ) : string
$str string The input string.
$use_enc string The encoding to be used. If null, the internal encoding will be used.
Результат string The modified string.

valid_data() публичный статический Метод

Determines if the passed string is valid character data (according to mbstring)
public static valid_data ( string $str, null $use_enc = null ) : boolean
$str string the string to check
$use_enc null
Результат boolean

Описание свойств

$hab_enc статическое публичное свойство

String holding the current encoding the class is using
static public $hab_enc