Sgss_String
Represents an encalsuled string with multibyte characters

Description

Implements:
Countable (internal interface), ArrayAccess (internal interface), IteratorAggregate (internal interface)
Author:
Matsuda Shota
Copyright:
(c) 2007-2008 Matsuda Shota
License:
http://creativecommons.org/licenses/GPL/2.0/
Located in:
/String.php (line 52)

Class overview

Accessor

read-only int $length

Character length of this string

Variables

protected Sgss_String_Charset_Interface $_charset

Character set converter

protected int $_length

Character length of this string

protected string $_value

String in the specified character set

Methods

__construct ([mixed $value = ""], [string|null $charset = null])

The constructor

string char (int $index)

Returns the character at the specified index of this string

array chars ()

Returns an array of all the characters in this string

int code (int $index)

Returns the unicode codepoint of the specified index of this string

array codes ()

Returns an array of all the unicode codepoints in this string

Sgss_String convert ([string|null $charset = null])

Returns the string object in the specified character set

int count ()
Iterator getIterator ()
int index (string|Sgss_String $str, [int $offset = 0], [boolean $reverse = false])

Returns the index at which the specified string first appears in this string

int length ()

Returns the character length of this string

boolean offsetExists (mixed $offset)
mixed offsetGet (mixed $offset)
mixed offsetSet (mixed $offset, mixed $value)
void offsetUnset (mixed $offset)
string|null substr (int $offset, [int|null $length = null])

Retruns the substring of this string with the specified offset and length

Sgss_String substring (int $offset, [int|null $length = null])

Retruns the substring object of this string with the specified offset and length

string value ([string|null $charset = null])

Returns the string in the specified character set

mixed __get (mixed $name)
string __toString ()

Variable detail

$_charset 

Character set converter

Signature:
protected Sgss_String_Charset_Interface $_charset


$_length 

Character length of this string

Signature:
protected int $_length


$_value 

String in the specified character set

Signature:
protected string $_value


Method detail

__construct

The constructor

Parameters:
  • mixed $value

    String in the specified character set

  • string|null $charset

    Character set used in the string

Uses:
Sgss_String_Charset::getInternal(), Sgss_String_Charset::factory()
Signature:
public __construct ([mixed $value = ""], [string|null $charset = null])


char

Returns the character at the specified index of this string

Parameters:
  • int $index

    Index of the character

Throws:
  • Sgss_String_Exception

    When the index out of bounds

Uses:
Sgss_String_Charset_Interface::char()
Used by:
Sgss_String_Iterator_Char::next(), Sgss_String_Iterator_Char::current()
Related subject:
chr()
Signature:
public string char (int $index)


chars

Returns an array of all the characters in this string

Uses:
Sgss_String_Charset_Interface::char()
Signature:
public array chars ()


code

Returns the unicode codepoint of the specified index of this string

Parameters:
  • int $index

    Index of the character

Throws:
  • Sgss_String_Exception

    When the index out of bounds

Uses:
Sgss_String_Charset_Interface::code()
Used by:
Sgss_String_Iterator_Code::next(), Sgss_String_Iterator_Code::current()
Related subject:
ord()
Signature:
public int code (int $index)


codes

Returns an array of all the unicode codepoints in this string

Uses:
Sgss_String_Charset_Interface::code()
Signature:
public array codes ()


convert

Returns the string object in the specified character set

Parameters:
  • string|null $charset

    Character set

Uses:
Sgss_String::value()
Signature:
public Sgss_String convert ([string|null $charset = null])


count

Specified by:
  • Countable::count
Related subject:
Countable::count()
Signature:
public int count ()


getIterator

Specified by:
  • IteratorAggregate::getIterator
Uses:
Sgss_String_Iterator_Char
Related subject:
IteratorAggregate::getIterator()
Signature:
public Iterator getIterator ()


index

Returns the index at which the specified string first appears in this string

Parameters:
  • string|Sgss_String $str

    String to search

  • int $offset

    Starting offset to search

  • boolean $reverse

    Whether to search from the end of this string

Uses:
Sgss_String_Charset_Interface::index()
Related subjects:
strrpos(), strpos()
Signature:
public int index (string|Sgss_String $str, [int $offset = 0], [boolean $reverse = false])


length

Returns the character length of this string

Used by:
Sgss_String_Iterator_Code::valid(), Sgss_String_Iterator_Code::next(), Sgss_String_Iterator_Char::next(), Sgss_String_Iterator_Char::valid()
Related subject:
strlen()
Signature:
public int length ()


offsetExists

Parameters:
  • mixed $offset
Specified by:
  • ArrayAccess::offsetExists
Related subject:
ArrayAccess::offsetExists()
Signature:
public boolean offsetExists (mixed $offset)


offsetGet

Parameters:
  • mixed $offset
Specified by:
  • ArrayAccess::offsetGet
Related subject:
ArrayAccess::offsetGet()
Signature:
public mixed offsetGet (mixed $offset)


offsetSet

Parameters:
  • mixed $offset
  • mixed $value
Specified by:
  • ArrayAccess::offsetSet
Related subject:
ArrayAccess::offsetSet()
Signature:
public mixed offsetSet (mixed $offset, mixed $value)


offsetUnset

Parameters:
  • mixed $offset
Specified by:
  • ArrayAccess::offsetUnset
Related subject:
ArrayAccess::offsetUnset()
Signature:
public void offsetUnset (mixed $offset)


substr

Retruns the substring of this string with the specified offset and length

Parameters:
  • int $offset

    Offset of the substring

  • int|null $length

    Length of the substring

Uses:
Sgss_String_Charset_Interface::substr()
Related subject:
Sgss_String::substr()
Signature:
public string|null substr (int $offset, [int|null $length = null])


substring

Retruns the substring object of this string with the specified offset and length

This is the same as substr() except the returned value is Sgss_String.

Parameters:
  • int $offset

    Offset of the substring

  • int|null $length

    Length of the substring

Uses:
Sgss_String_Charset_Interface::substr()
Signature:
public Sgss_String substring (int $offset, [int|null $length = null])


value

Returns the string in the specified character set

Parameters:
  • string|null $charset

    Character set

Uses:
Sgss_String_Charset_Interface::convert()
Used by:
Sgss_String::convert()
Signature:
public string value ([string|null $charset = null])


__get

Parameters:
  • mixed $name
Signature:
public mixed __get (mixed $name)


__toString

Signature:
public string __toString ()