class vB_String

String

Traits

Constants

INVALID_CUSTOM_URL_CHAR

Properties

static $convertionMap

Methods

__sleep()

No description

__wakeup()

No description

static boolean
isValidEmail(string $email)

Tests a string to see if it's a valid email address

static string
htmlSpecialCharsUni($text, $entities = true)

Unicode-safe version of htmlspecialchars()

static 
htmlSpecialCharsUniCallback($matches)

No description

static bool
isEmpty(string $val)

No description

static string
getPreviewText(string $text, int $customLength = 0)

Takes a string of arbitrary length and returns a preview string of maximum arbitrary length Strips various html code from the text.

static 
getPlainText($text)

Get's a version of the text without markup. Same as getPreviewText without truncating the length.

static string
fetchCensoredText(string $text)

Replaces any instances of words censored in $options['censorwords'] with $options['censorchar']

static string
stripBbcode(string $message, boolean $stripquotes = false, boolean $fast_and_dirty = false, boolean $showlinks = true, boolean $stripimg = false, boolean $keepquotetags = false)

Strips away bbcode from a given string, leaving plain text

static string
stripBlankAscii(string $text, string $replace)

Replaces any non-printing ASCII characters with the specified string.

static string,
getTempCharset()

This is a temporary function used to get the stylevar 'charset' (added for presentation).

static string
fetchWordWrappedString(integer $text, string $limit, string $wraptext = ' ')

Attempts to intelligently wrap excessively long strings onto multiple lines

static 
stripos($haystack, $needle, $offset = 0)

Case-insensitive version of strpos(). Defined if it does not exist.

static string
stripNcrs(string $str)

Strips NCRs from a string.

static 
getCharset()

Gets the current charset

static string
toCharset(string|array $in, string $in_encoding, string $target_encoding = false, string $do_ncr = true)

Converts a string from one character encoding to another.

static string
convertStringToCurrentCharset($string)

Converts a string to the desired character set if possible. Wrapper for the callback

static string
cleanUserName($username)

Cleans a username to current charset

static string
convertUnicodeCharToCharset(integer $unicode_int, string $charset)

Converts a single unicode character to the desired character set if possible.

static string
jsonEncode(mixed $value, int $options = 0)

Encodes a value as a JSON string, attempting to correct invalid UTF8 characters that would otherwise make PHP's json_encode fail.

static string
toUtf8(string $in, string $charset = false, bool $strip = true)

Converts a string to utf8

static 
stripInvalidUtf8($in)

No description

static integer
vbStrlen(string $string, boolean $unHtmlSpecialChars = false)

Attempts to do a character-based strlen on data that might contain HTML entities.

static String
getUrlIdent(String $title, String $encoding = false)

Get a valid UrlIdent value from a title removing special chars.

static string
vBStrToLower(string $string, string $encoding = false)

Converts A-Z to a-z, doesn't change any other characters

static string
unHtmlSpecialChars(string $text, boolean $doUniCode = false)

Returns a string where HTML entities have been converted back to their original characters

static 
convertIntToUtf8Pregmatch($matches)

Callback for preg_replace_callback in unHtmlSpecialChars

static string
convertIntToUtf8(integer $intval)

Converts an integer into a UTF-8 character string

static string
vbChop(string $string, integer $length)

Chops off a string at a specific length, counting entities as once character and using multibyte-safe functions if available. Copied from presentation method of the same name.

static string
ncrEncode(string $str, bool $skip_ascii = false, bool $skip_win = false)

Converts a UTF-8 string into unicode NCR equivelants.

static string
latinise(string $str)

Translates some special characters to their latin form

static string
stripTags(string $str)

Strip HTML Tags, HTML comments, and PHP Tags from a string

static mixed
parseUrl(string $url, int $component = -1)

UTF-8 Safe Parse_url http://us3.php.net/manual/en/function.parse-url.php

static 
jsonEncodeLocalCharset($value, $options = 0, $depth = 512)

No description

static string
encodeUtf8Url(string $url)

Encode a UTF-8 Encoded URL and urlencode it while leaving control characters in tact.

static 
decodeUtf8Url($url)

No description

static 
getCssMinifiedText($text)

No description

static string
fetchTrimmedTitle(string $title, integer $chars, boolean $append = true)

Trims a string to the specified length while keeping whole words

static 
isVbCharset($charset)

No description

static 
areCharsetsEqual($charset1, $charset2)

No description

Details

in vB_Trait_NoSerialize at line 15
__sleep()

in vB_Trait_NoSerialize at line 20
__wakeup()

at line 44
static boolean isValidEmail(string $email)

Tests a string to see if it's a valid email address

Parameters

string $email Email address

Return Value

boolean

at line 57
static string htmlSpecialCharsUni($text, $entities = true)

Unicode-safe version of htmlspecialchars()

Parameters

$text
$entities

Return Value

string

at line 85
static protected htmlSpecialCharsUniCallback($matches)

Parameters

$matches

at line 127
static bool isEmpty(string $val)

Parameters

string $val

Return Value

bool

at line 142
static string getPreviewText(string $text, int $customLength = 0)

Takes a string of arbitrary length and returns a preview string of maximum arbitrary length Strips various html code from the text.

Parameters

string $text -- raw text to get a preview from
int $customLength -- approximate lenght of preview (will attempt to break on word boundary) 0 means use the value configured in the options (or 150 if that is also not set). This is the default value of the parameter.

Return Value

string

at line 186
static getPlainText($text)

Get's a version of the text without markup. Same as getPreviewText without truncating the length.

Parameters

$text

at line 241
static string fetchCensoredText(string $text)

Replaces any instances of words censored in $options['censorwords'] with $options['censorchar']

Parameters

string $text Text to be censored

Return Value

string

at line 305
static string stripBbcode(string $message, boolean $stripquotes = false, boolean $fast_and_dirty = false, boolean $showlinks = true, boolean $stripimg = false, boolean $keepquotetags = false)

Strips away bbcode from a given string, leaving plain text

Parameters

string $message Text to be stripped of bbcode tags
boolean $stripquotes If true, strip away quote tags AND their contents
boolean $fast_and_dirty If true, use the fast-and-dirty method rather than the shiny and nice method
boolean $showlinks If true, display the url of the link in parenthesis after the link text
boolean $stripimg If true, strip away img/video tags and their contents
boolean $keepquotetags If true, keep [quote] tags. Useful for API.

Return Value

string

at line 391
static string stripBlankAscii(string $text, string $replace)

Replaces any non-printing ASCII characters with the specified string.

This also supports removing Unicode characters automatically when the entered value is >255 or starts with a 'u'.

Parameters

string $text Text to be processed
string $replace String with which to replace non-printing characters

Return Value

string

at line 444
static string, getTempCharset()

This is a temporary function used to get the stylevar 'charset' (added for presentation).

Return Value

string, stylevar charset value

at line 469
static string fetchWordWrappedString(integer $text, string $limit, string $wraptext = ' ')

Attempts to intelligently wrap excessively long strings onto multiple lines

Parameters

integer $text max word wrap length
string $limit Text to be wrapped
string $wraptext Text to insert at the wrap point

Return Value

string

at line 498
static stripos($haystack, $needle, $offset = 0)

Case-insensitive version of strpos(). Defined if it does not exist.

Parameters

$haystack
$needle
$offset

at line 516
static string stripNcrs(string $str)

Strips NCRs from a string.

Parameters

string $str The string to strip from

Return Value

string The result

at line 524
static getCharset()

Gets the current charset

at line 556
static string toCharset(string|array $in, string $in_encoding, string $target_encoding = false, string $do_ncr = true)

Converts a string from one character encoding to another.

If the target encoding is not specified then it will be resolved from the current language settings.

Parameters

string|array $in The string/array to convert
string $in_encoding The source encoding
string $target_encoding The target encoding -- defaults to the current encoding
string $do_ncr Whether to do ncr encoding of special characters.

Return Value

string The target encoding

at line 641
static string convertStringToCurrentCharset($string)

Converts a string to the desired character set if possible. Wrapper for the callback

Parameters

$string

Return Value

string Character in desired character set or as an HTML entity

at line 660
static string cleanUserName($username)

Cleans a username to current charset

Parameters

$username

Return Value

string Character in desired character set or as an HTML entity

at line 679
static string convertUnicodeCharToCharset(integer $unicode_int, string $charset)

Converts a single unicode character to the desired character set if possible.

Attempts to use iconv if it's available. Callback function for the regular expression in convert_urlencoded_unicode.

Parameters

integer $unicode_int Unicode code point value
string $charset Character to convert to

Return Value

string Character in desired character set or as an HTML entity

at line 711
static string jsonEncode(mixed $value, int $options = 0)

Encodes a value as a JSON string, attempting to correct invalid UTF8 characters that would otherwise make PHP's json_encode fail.

Parameters

mixed $value Value to encode
int $options Options for json_encode

Return Value

string Encoded string

at line 739
static string toUtf8(string $in, string $charset = false, bool $strip = true)

Converts a string to utf8

Parameters

string $in The variable to clean
string $charset The source charset
bool $strip Whether to strip invalid utf8 if we couldn't convert

Return Value

string The reencoded string

at line 775
static stripInvalidUtf8($in)

Parameters

$in

at line 807
static integer vbStrlen(string $string, boolean $unHtmlSpecialChars = false)

Attempts to do a character-based strlen on data that might contain HTML entities.

By default, it only converts numeric entities but can optional convert ", <, etc. Uses a multi-byte aware function to do the counting if available.

Parameters

string $string String to be measured
boolean $unHtmlSpecialChars If true, run unhtmlspecialchars on string to count " as one, etc.

Return Value

integer Length of string

at line 838
static String getUrlIdent(String $title, String $encoding = false)

Get a valid UrlIdent value from a title removing special chars.

Parameters

String $title The title text to be converted.
String $encoding Encoding of the string. (Optional)

Return Value

String A valid urlident encoded in UTF-8

at line 872
static string vBStrToLower(string $string, string $encoding = false)

Converts A-Z to a-z, doesn't change any other characters

Parameters

string $string String to convert to lowercase
string $encoding Encoding of the string (Optional)

Return Value

string Lowercase string

at line 900
static string unHtmlSpecialChars(string $text, boolean $doUniCode = false)

Returns a string where HTML entities have been converted back to their original characters

Parameters

string $text String to be parsed
boolean $doUniCode Convert unicode characters back from HTML entities?

Return Value

string

at line 915
static protected convertIntToUtf8Pregmatch($matches)

Callback for preg_replace_callback in unHtmlSpecialChars

Parameters

$matches

at line 927
static string convertIntToUtf8(integer $intval)

Converts an integer into a UTF-8 character string

Parameters

integer $intval Integer to be converted

Return Value

string

at line 967
static string vbChop(string $string, integer $length)

Chops off a string at a specific length, counting entities as once character and using multibyte-safe functions if available. Copied from presentation method of the same name.

Parameters

string $string String to chop
integer $length Number of characters to chop at

Return Value

string Chopped string

at line 1023
static string ncrEncode(string $str, bool $skip_ascii = false, bool $skip_win = false)

Converts a UTF-8 string into unicode NCR equivelants.

Parameters

string $str String to encode
bool $skip_ascii Only ncrencode unicode bytes
bool $skip_win If true and $skip_ascii is true, it will skip windows-1252 extended chars

Return Value

string Encoded string

at line 1070
static string latinise(string $str)

Translates some special characters to their latin form

Parameters

string $str

Return Value

string

at line 1082
static string stripTags(string $str)

Strip HTML Tags, HTML comments, and PHP Tags from a string

Parameters

string $str

Return Value

string

at line 1096
static mixed parseUrl(string $url, int $component = -1)

UTF-8 Safe Parse_url http://us3.php.net/manual/en/function.parse-url.php

Parameters

string $url
int $component

Return Value

mixed

at line 1164
static jsonEncodeLocalCharset($value, $options = 0, $depth = 512)

Parameters

$value
$options
$depth

at line 1189
static string encodeUtf8Url(string $url)

Encode a UTF-8 Encoded URL and urlencode it while leaving control characters in tact.

(It can also work with single byte encodings, but its purpose is to supply UTF-8 urls on non UTF-8 forums.)

Parameters

string $url url

Return Value

string

at line 1244
static decodeUtf8Url($url)

Parameters

$url

at line 1279
static getCssMinifiedText($text)

Parameters

$text

at line 1350
static string fetchTrimmedTitle(string $title, integer $chars, boolean $append = true)

Trims a string to the specified length while keeping whole words

Parameters

string $title String to be trimmed
integer $chars Number of characters to aim for in the trimmed string. If 0 return the entire string.
boolean $append Append "..." to shortened text

Return Value

string

at line 1387
static isVbCharset($charset)

Parameters

$charset

at line 1392
static areCharsetsEqual($charset1, $charset2)

Parameters

$charset1
$charset2