Static Public Member Functions | Public Attributes | Static Public Attributes

MultiByte Class Reference

List of all members.

Static Public Member Functions

static hab_encoding ($use_enc=null)
static library ($new_library=null)
static convert_encoding ($str, $use_enc=null, $from_enc=null)
static detect_encoding ($str)
static detect_bom_encoding ($source_contents)
static substr ($str, $begin, $len=null, $use_enc=null)
static strlen ($str, $use_enc=null)
static strpos ($haysack, $needle, $offset=0, $use_enc=null)
static stripos ($haysack, $needle, $offset=0, $use_enc=null)
static strrpos ($haysack, $needle, $offset=0, $use_enc=null)
static strripos ($haysack, $needle, $offset=0, $use_enc=null)
static strtolower ($str, $use_enc=null)
static strtoupper ($str, $use_enc=null)
static valid_data ($str, $use_enc=null)
static ucfirst ($str, $use_enc=null)
static lcfirst ($str, $use_enc=null)
static str_replace ($search, $replace, $subject, &$count=0, $use_enc=null)
static str_ireplace ($search, $replace, $subject, &$count=0, $use_enc=null)
static ucwords ($str, $use_enc=null)

Public Attributes

const USE_MBSTRING = 1

Static Public Attributes

static $hab_enc = 'UTF-8'

Detailed Description

Habari MultiByte Class

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.

Definition at line 18 of file multibyte.php.


Member Function Documentation

static MultiByte::convert_encoding ( str,
use_enc = null,
from_enc = null 
) [static]

Converts a string's encoding to a new encoding

Parameters:
$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.
Returns:
mixed The source string in the new encoding or boolean false.

Definition at line 101 of file multibyte.php.

Referenced by WPImport::action_auth_ajax_wp_import_comments(), WPImport::action_auth_ajax_wp_import_posts(), and Pingback::xmlrpc_pingback__ping().

static MultiByte::detect_bom_encoding ( source_contents  )  [static]

Detects the encoding being used for a string using the existence of a byte order mark

Parameters:
$source_contents string. The string whose encoding is being detected
Returns:
mixed The source string's detected encoding, or boolean false.

Definition at line 153 of file multibyte.php.

Referenced by Pingback::xmlrpc_pingback__ping().

static MultiByte::detect_encoding ( str  )  [static]

Detects the encoding being used for a string

Parameters:
$str string. The string whose encoding is being detected
Returns:
mixed The source string's detected encoding, or boolean false.

Definition at line 127 of file multibyte.php.

Referenced by convert_encoding().

static MultiByte::hab_encoding ( use_enc = null  )  [static]

Sets and returns the internal encoding.

Parameters:
$use_enc string. The encoding to be used
Returns:
string. If $enc is null, returns the current encoding. If $enc is not null, returns the old encoding

Definition at line 48 of file multibyte.php.

Referenced by Theme::add_template_vars(), InputFilter::filter_html_elements(), and Pingback::xmlrpc_pingback__ping().

static MultiByte::lcfirst ( str,
use_enc = null 
) [static]

Makes a string's first character lowercase

See also:
http://php.net/ucfirst
Parameters:
string $str The string to lowercase.
string $use_enc The encoding to be used. If null, the internal encoding will be used.
Returns:
string The lowercased string.

Definition at line 472 of file multibyte.php.

static MultiByte::library ( new_library = null  )  [static]

Sets and returns the multibyte library being used internally

Parameters:
int $new_library 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.
Returns:
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.

Definition at line 69 of file multibyte.php.

static MultiByte::str_ireplace ( search,
replace,
subject,
&$  count = 0,
use_enc = null 
) [static]

Replace all occurrences of the search string with the replacement string.

See also:
http://php.net/str_ireplace
Parameters:
mixed $search A string or an array of strings to search for.
mixed $replace A string or an array of strings to replace search values with.
string $subject The string to perform the search and replace on.
int $count If passed, this value will hold the number of matched and replaced needles.
string $use_enc The encoding to be used. If null, the internal encoding will be used.
Returns:
string The subject with replaced values.

Definition at line 634 of file multibyte.php.

static MultiByte::str_replace ( search,
replace,
subject,
&$  count = 0,
use_enc = null 
) [static]

Replace all occurrences of the search string with the replacement string.

See also:
http://php.net/str_replace
Parameters:
mixed $search A string or an array of strings to search for.
mixed $replace A string or an array of strings to replace search values with.
string $subject The string to perform the search and replace on.
int $count If passed, this value will hold the number of matched and replaced needles.
string $use_enc The encoding to be used. If null, the internal encoding will be used.
Returns:
string The subject with replaced values.

Definition at line 523 of file multibyte.php.

Referenced by Terms::parse().

static MultiByte::stripos ( haysack,
needle,
offset = 0,
use_enc = null 
) [static]

Find position of first occurrence of string in a string. Case insensitive.

Parameters:
$haysack string. The string being checked.
$needle. string. The position counted from the beginning of haystack .
$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.
Returns:
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.

Definition at line 272 of file multibyte.php.

Referenced by str_ireplace().

static MultiByte::strlen ( str,
use_enc = null 
) [static]

Gets the length of a string in characters

Parameters:
$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.
Returns:
integer. The length in characters of the string, or the length in bytes if a valid multibyte library isn't loaded.

Definition at line 213 of file multibyte.php.

Referenced by Format::autop(), Plugins::deactivate_plugin(), URL::get_from_filesystem(), Site::get_url(), Format::more(), Plugins::set_present(), str_ireplace(), str_replace(), substr(), and Utils::truncate().

static MultiByte::strpos ( haysack,
needle,
offset = 0,
use_enc = null 
) [static]

Find position of first occurrence of string in a string

Parameters:
$haysack string. The string being checked.
$needle. string. The position counted from the beginning of haystack .
$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.
Returns:
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.

Definition at line 243 of file multibyte.php.

Referenced by AdminPostsHandler::ajax_media(), and str_replace().

static MultiByte::strripos ( haysack,
needle,
offset = 0,
use_enc = null 
) [static]

Find position of last occurrence of string in a string. Case insensitive.

Parameters:
$haysack string. The string being checked.
$needle. string. The position counted from the beginning of haystack .
$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.
Returns:
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.

Definition at line 332 of file multibyte.php.

static MultiByte::strrpos ( haysack,
needle,
offset = 0,
use_enc = null 
) [static]

function strrpos

Find position of last occurrence of string in a string.

Parameters:
$haysack string. The string being checked.
$needle. string. The position counted from the beginning of haystack .
$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.
Returns:
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.

Definition at line 303 of file multibyte.php.

static MultiByte::strtolower ( str,
use_enc = null 
) [static]

function 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.

Parameters:
$str string. The string to lowercase
$use_enc string. The encoding to be used. If not set, the internal encoding will be used.
Returns:
string. The lowercased string.

Definition at line 360 of file multibyte.php.

Referenced by ACL::_filter_token_description_display(), EventLog::get(), Users::get(), Posts::get(), Comments::get(), Plugins::is_loaded(), lcfirst(), Comments::search_to_get(), Utils::slugify(), Post::status(), and Post::type().

static MultiByte::strtoupper ( str,
use_enc = null 
) [static]

Converts a multibyte string to uppercase. If a valid multibyte library isn't loaded, strtoupper() will be used, which can lead to unexpected results.

Parameters:
$str string. The string to uppercase
$use_enc string. The encoding to be used. If not set, the internal encoding will be used.
Returns:
string. The uppercased string.

Definition at line 387 of file multibyte.php.

Referenced by ucfirst().

static MultiByte::substr ( str,
begin,
len = null,
use_enc = null 
) [static]

Get a section of a string

Parameters:
$str string. The original string
$begin. integer. The beginning character of the string to return.
$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.
Returns:
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.

Definition at line 184 of file multibyte.php.

Referenced by Plugins::activate_plugin(), AdminPostsHandler::ajax_media(), Plugins::deactivate_plugin(), detect_bom_encoding(), RemoteRequest::get_contents(), URL::get_from_filesystem(), Site::get_url(), lcfirst(), Tags::parse_url_tags(), Plugins::set_present(), str_ireplace(), str_replace(), Utils::truncate(), ucfirst(), and Session::write().

static MultiByte::ucfirst ( str,
use_enc = null 
) [static]

Makes a string's first character uppercase

See also:
http://php.net/ucfirst
Parameters:
string $str The string to capitalize.
string $use_enc The encoding to be used. If null, the internal encoding will be used.
Returns:
string The capitalized string.

Definition at line 433 of file multibyte.php.

Referenced by CoreDashModules::filter_dash_module_post_types_and_statuses(), AdminCommentsHandler::post_comments(), AdminPostsHandler::post_posts(), and ucwords().

static MultiByte::ucwords ( str,
use_enc = null 
) [static]

Uppercase the first character of each word in a string.

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).

See also:
http://php.net/ucwords
Parameters:
string $str The input string.
string $use_enc The encoding to be used. If null, the internal encoding will be used.
Returns:
string The modified string.

Definition at line 746 of file multibyte.php.

Referenced by AdminHandler::setup_admin_theme().

static MultiByte::valid_data ( str,
use_enc = null 
) [static]

Determines if the passed string is valid character data (according to mbstring)

Parameters:
string $str the string to check
null $use_enc
Returns:
bool

Definition at line 411 of file multibyte.php.

Referenced by InputFilter::filter().


The documentation for this class was generated from the following file: