Abstract Class JString

Description

String handling class for utf-8 data Wraps the phputf8 library All functions assume the validity of utf-8 strings.

  • abstract:
  • since: 11.1

Located in /libraries/joomla/string/string.php (line 47)


	
			
Variable Summary
 static array $incrementStyles
Method Summary
 static boolean compliant (string $str)
 static string increment (string $string, [string $style = 'default'], [integer $n = 0])
 static string ltrim (string $str, [string $charlist = false])
 static mixed parse_url (string $url)
 static string rtrim (string $str, [string $charlist = false])
 static array splitCamelCase (string $string)
 static integer strcasecmp (string $str1, string $str2, [mixed $locale = false])
 static integer strcmp (string $str1, string $str2, [mixed $locale = false])
 static integer strcspn (string $str, string $mask, [integer $start = null], [integer $length = null])
 static string stristr (string $str, string $search)
 static integer strlen (string $str)
 static mixed strpos (string $str, string $search, [integer $offset = false])
 static string strrev (string $str)
 static mixed strrpos (string $str, string $search, [integer $offset = 0])
 static integer strspn (string $str, string $mask, [integer $start = null], [integer $length = null])
 static mixed strtolower (string $str)
 static mixed strtoupper (string $str)
 static string str_ireplace (string $search, string $replace, string $str, [integer $count = null])
 static array str_split (string $str, [integer $split_len = 1])
 static mixed substr (string $str, integer $offset, [integer $length = false])
 static string substr_replace (string $str, string $repl, integer $start, [integer $length = null])
 static mixed transcode (string $source, string $from_encoding, string $to_encoding)
 static string trim (string $str, [string $charlist = false])
 static string ucfirst (string $str, [string $delimiter = null], [string $newDelimiter = null])
 static string ucwords (string $str)
 static boolean valid (string $str)
Variables
static array $incrementStyles = array(
'dash' => array(
'#-(\d+)$#',
'-%d'
),'default'=>array(array('#\((\d+)\)$#','#\(\d+\)$#'),array(' (%d)','(%d)'),),)
(line 55)

Increment styles.

  • since: 11.3
  • access: protected
Methods
static compliant (line 919)

Tests whether a string complies as UTF-8. This will be much

faster than utf8_is_valid but will pass five and six octet UTF-8 sequences, which are not supported by Unicode and so cannot be displayed correctly in a browser. In other words it is not as strict as utf8_is_valid but it's faster. If you use it to validate user input, you place yourself at the risk that attackers will be able to inject 5 and 6 byte sequences (which may or may not be a significant risk, depending on what you are are doing)

  • return: TRUE if string is valid UTF-8
  • see: JString::valid()
  • see: 54805
  • since: 11.1
  • access: public
static boolean compliant (string $str)
  • string $str: UTF-8 string to check
static increment (line 107)

Increments a trailing number in a string.

Used to easily create distinct labels when copying objects. The method has the following styles:

default: "Label" becomes "Label (2)" dash: "Label" becomes "Label-2"

  • return: The incremented string.
  • since: 11.3
  • access: public
static string increment (string $string, [string $style = 'default'], [integer $n = 0])
  • string $string: The source string.
  • string $style: The the style (default|dash).
  • integer $n: If supplied, this number is used for the copy, otherwise it is the 'next' number.
static ltrim (line 585)

UTF-8 aware replacement for ltrim()

Strip whitespace (or other characters) from the beginning of a string You only need to use this if you are supplying the charlist optional arg and it contains UTF-8 characters. Otherwise ltrim will work normally on a UTF-8 string

static string ltrim (string $str, [string $charlist = false])
  • string $str: The string to be trimmed
  • string $charlist: The optional charlist of additional characters to trim
static parse_url (line 945)

Does a UTF-8 safe version of PHP parse_url function

static mixed parse_url (string $url)
  • string $url: URL to parse
static rtrim (line 619)

UTF-8 aware replacement for rtrim()

Strip whitespace (or other characters) from the end of a string You only need to use this if you are supplying the charlist optional arg and it contains UTF-8 characters. Otherwise rtrim will work normally on a UTF-8 string

static string rtrim (string $str, [string $charlist = false])
  • string $str: The string to be trimmed
  • string $charlist: The optional charlist of additional characters to trim
static splitCamelCase (line 84)

Split a string in camel case format

"FooBarABCDef" becomes array("Foo", "Bar", "ABC", "Def"); "JFooBar" becomes array("J", "Foo", "Bar"); "J001FooBar002" becomes array("J001", "Foo", "Bar002"); "abcDef" becomes array("abc", "Def"); "abc_defGhi_Jkl" becomes array("abc_def", "Ghi_Jkl"); "ThisIsA_NASAAstronaut" becomes array("This", "Is", "A_NASA", "Astronaut")), "JohnFitzgerald_Kennedy" becomes array("John", "Fitzgerald_Kennedy")),

  • return: The splitted string.
  • deprecated: 12.3 (Platform) & 4.0 (CMS) - Use JStringNormalise::fromCamelCase()
  • since: 11.3
  • access: public
static array splitCamelCase (string $string)
  • string $string: The source string.
static strcasecmp (line 337)

UTF-8/LOCALE aware alternative to strcasecmp A case insensitive string comparison

static integer strcasecmp (string $str1, string $str2, [mixed $locale = false])
  • string $str1: string 1 to compare
  • string $str2: string 2 to compare
  • mixed $locale: The locale used by strcoll or false to use classical comparison
static strcmp (line 397)

UTF-8/LOCALE aware alternative to strcmp A case sensitive string comparison

static integer strcmp (string $str1, string $str2, [mixed $locale = false])
  • string $str1: string 1 to compare
  • string $str2: string 2 to compare
  • mixed $locale: The locale used by strcoll or false to use classical comparison
static strcspn (line 453)

UTF-8 aware alternative to strcspn Find length of initial segment not matching mask

  • return: The length of the initial segment of str1 which does not contain any of the characters in str2
  • see: http://www.php.net/strcspn
  • since: 11.1
  • access: public
static integer strcspn (string $str, string $mask, [integer $start = null], [integer $length = null])
  • string $str: The string to process
  • string $mask: The mask
  • integer $start: Optional starting character position (in characters)
  • integer $length: Optional length
static stristr (line 485)

UTF-8 aware alternative to stristr Returns all of haystack from the first occurrence of needle to the end.

needle and haystack are examined in a case-insensitive manner Find first occurrence of a string using case insensitive comparison

static string stristr (string $str, string $search)
  • string $str: The haystack
  • string $search: The needle
static strlen (line 270)

UTF-8 aware alternative to strlen.

Returns the number of characters in the string (NOT THE NUMBER OF BYTES),

static integer strlen (string $str)
  • string $str: UTF-8 string.
static strpos (line 162)

UTF-8 aware alternative to strpos.

Find position of first occurrence of a string.

  • return: Number of characters before the first match or FALSE on failure
  • see: http://www.php.net/strpos
  • since: 11.1
  • access: public
static mixed strpos (string $str, string $search, [integer $offset = false])
  • string $str: String being examined
  • string $search: String being searched for
  • integer $offset: Optional, specifies the position from which the search should be performed
static strrev (line 503)

UTF-8 aware alternative to strrev Reverse a string

static string strrev (string $str)
  • string $str: String to be reversed
static strrpos (line 187)

UTF-8 aware alternative to strrpos Finds position of last occurrence of a string

  • return: Number of characters before the last match or false on failure
  • see: http://www.php.net/strrpos
  • since: 11.1
  • access: public
static mixed strrpos (string $str, string $search, [integer $offset = 0])
  • string $str: String being examined.
  • string $search: String being searched for.
  • integer $offset: Offset from the left of the string.
static strspn (line 524)

UTF-8 aware alternative to strspn Find length of initial segment matching mask

static integer strspn (string $str, string $mask, [integer $start = null], [integer $length = null])
  • string $str: The haystack
  • string $mask: The mask
  • integer $start: Start optional
  • integer $length: Length optional
static strtolower (line 233)

UTF-8 aware alternative to strtlower

Make a string lowercase Note: The concept of a characters "case" only exists is some alphabets such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does not exist in the Chinese alphabet, for example. See Unicode Standard Annex #21: Case Mappings

static mixed strtolower (string $str)
  • string $str: String being processed
static strtoupper (line 253)

UTF-8 aware alternative to strtoupper

Make a string uppercase Note: The concept of a characters "case" only exists is some alphabets such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does not exist in the Chinese alphabet, for example. See Unicode Standard Annex #21: Case Mappings

static mixed strtoupper (string $str)
  • string $str: String being processed
static str_ireplace (line 289)

UTF-8 aware alternative to str_ireplace Case-insensitive version of str_replace

static string str_ireplace (string $search, string $replace, string $str, [integer $count = null])
  • string $search: String to search
  • string $replace: Existing string to replace
  • string $str: New string to replace with
  • integer $count: Optional count value to be passed by referene
static str_split (line 315)

UTF-8 aware alternative to str_split Convert a string to an array

static array str_split (string $str, [integer $split_len = 1])
  • string $str: UTF-8 encoded string to process
  • integer $split_len: Number to characters to split string by
static substr (line 205)

UTF-8 aware alternative to substr Return part of a string given character offset (and optionally length)

static mixed substr (string $str, integer $offset, [integer $length = false])
  • string $str: String being processed
  • integer $offset: Number of UTF-8 characters offset (from left)
  • integer $length: Optional length in UTF-8 characters from offset
static substr_replace (line 556)

UTF-8 aware substr_replace Replace text within a portion of a string

static string substr_replace (string $str, string $repl, integer $start, [integer $length = null])
  • string $str: The haystack
  • string $repl: The replacement string
  • integer $start: Start
  • integer $length: Length (optional)
static transcode (line 736)

Transcode a string.

static mixed transcode (string $source, string $from_encoding, string $to_encoding)
  • string $source: The string to transcode.
  • string $from_encoding: The source encoding.
  • string $to_encoding: The target encoding.
static trim (line 653)

UTF-8 aware replacement for trim()

Strip whitespace (or other characters) from the beginning and end of a string Note: you only need to use this if you are supplying the charlist optional arg and it contains UTF-8 characters. Otherwise trim will work normally on a UTF-8 string

static string trim (string $str, [string $charlist = false])
  • string $str: The string to be trimmed
  • string $charlist: The optional charlist of additional characters to trim
static ucfirst (line 687)

UTF-8 aware alternative to ucfirst Make a string's first character uppercase or all words' first character uppercase

  • return: If $delimiter is null, return the string with first character as upper case (if applicable) else consider the string of words separated by the delimiter, apply the ucfirst to each words and return the string with the new delimiter
  • see: http://www.php.net/ucfirst
  • since: 11.1
  • access: public
static string ucfirst (string $str, [string $delimiter = null], [string $newDelimiter = null])
  • string $str: String to be processed
  • string $delimiter: The words delimiter (null means do not split the string)
  • string $newDelimiter: The new words delimiter (null means equal to $delimiter)
static ucwords (line 716)

UTF-8 aware alternative to ucwords Uppercase the first character of each word in a string

static string ucwords (string $str)
  • string $str: String to be processed
static valid (line 767)

Tests a string as to whether it's valid UTF-8 and supported by the Unicode standard.

Note: this function has been modified to simple return true or false.

static boolean valid (string $str)
  • string $str: UTF-8 encoded string.

Documentation generated on Tue, 19 Nov 2013 15:14:34 +0100 by phpDocumentor 1.4.3