ultimix
text_1_0_0 Class Reference

Public Member Functions

 __construct ()
 explode_into_words ($String, $MaxWordLength=80)
 remove_bom ($Str)
 common_prefix (&$Strings)
 trim_common_prefix (&$Strings, $CommonPrefix=false)
 detect_encoding ($Content)
 iconv ($InCharset, $OutCharset, $Data)

Data Fields

 $Tags = false
 $WINPatternL = '~([\270])|([\340-\347])|([\350-\357])|([\360-\367])|([\370-\377])~s'
 $WINPatternU = '~([\250])|([\300-\307])|([\310-\317])|([\320-\327])|([\330-\337])~s'
 $KOIPatternL = '~([\243])|([\300-\307])|([\310-\317])|([\320-\327])|([\330-\337])~s'
 $KOIPatternU = '~([\263])|([\340-\347])|([\350-\357])|([\360-\367])|([\370-\377])~s'
 $Patterns = array()

Detailed Description

String utilities.

Author
Dodonov A.A.

Definition at line 26 of file text.php.

Constructor & Destructor Documentation

__construct ( )

Constructor.

Author
Dodonov A.A.

Definition at line 50 of file text.php.

{
try
{
$this->Tags = get_package( 'string::tags' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Member Function Documentation

common_prefix ( $Strings)

Function removes BOM .

Parameters
$Strings- Strings to process.
Returns
Common prefix.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 178 of file text.php.

{
try
{
if( isset( $Strings[ 0 ] ) === false )
{
return( '' );
}
$CommonPrefix = '';
$MaxLength = strlen( $Strings[ 0 ] );
for( $i = 0 ; $i < $MaxLength ; $i++ )
{
foreach( $Strings as $j => $String )
{
if( $Strings[ 0 ][ $i ] != $String[ $i ] )
{
return( $CommonPrefix );
}
}
$CommonPrefix .= $Strings[ 0 ][ $i ];
}
return( $CommonPrefix );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
detect_encoding (   $Content)

Function detects encoding.

Parameters
$Strings- Strings to process.
Returns
cp1251, koi8-r, iso-8859-5, x-mac-cyrillic, ibm866, ibm855, utf8 or false.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 692 of file text.php.

{
try
{
$Charsets = array ( 'w' => 0, 'k' => 0, 'i' => 0, 'm' => 0, 'a' => 0, 'c' => 0, 'u' => 0 );
$this->try_encoding( $Charsets , $Content , 'w' );
$this->try_encoding( $Charsets , $Content , 'k' );
$this->try_encoding( $Charsets , $Content , 'i' );
$this->try_encoding( $Charsets , $Content , 'm' );
$this->try_encoding( $Charsets , $Content , 'a' );
$this->try_encoding( $Charsets , $Content , 'c' );
$this->try_encoding( $Charsets , $Content , 'u' );
return( $this->analize_detection_results( $Charsets ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
explode_into_words (   $String,
  $MaxWordLength = 80 
)

Function formats $String so the word's length won't be bigger than $MaxWordLength symbols.

Parameters
$String- Processing string.
$MaxWordLength- Maximum count of the letters in the word.
Returns
Formatted data.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 88 of file text.php.

{
try
{
$RawWords = strip_tags( $this->Tags->compile_phpbb_tags( $String ) );
$RawWords = str_replace( "\r" , ' ' , $RawWords );
$RawWords = str_replace( "\n" , ' ' , $RawWords );
$RawWords = explode( ' ' , $RawWords );
foreach( $RawWords as $Key => $Value )
{
if( strlen( $Value ) > $MaxWordLength )
{
$Parts = chunk_split( $Value , $MaxWordLength , '[br]' );
$String = str_replace( $Value , $Parts , $String );
}
}
return( $String );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
iconv (   $InCharset,
  $OutCharset,
  $Data 
)

Function decodes string data.

Parameters
$InCharset- The input charset.
$OutCharset- The output charset.
$Data- Data to decode.
Returns
Decoded data.
Note
This function works recursively for objects and arrays.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 754 of file text.php.

{
try
{
if( is_array( $Data ) || is_object( $Data ) )
{
foreach( $Data as $Key => $Value )
{
set_field( $Data , $Key , $this->iconv( $InCharset , $OutCharset , $Value ) );
}
return( $Data );
}
else
{
if( $InCharset === false )
{
$InCharset = $this->detect_encoding( $Data );
}
return( @iconv( $InCharset , $OutCharset , $Data ) );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
remove_bom (   $Str)

Function removes BOM .

Parameters
$Str- String to process.
Returns
Processed string.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 136 of file text.php.

{
try
{
if( $Str !== false && strlen( $Str ) )
{
if( ord( @$Str[ 0 ] ) === 239 && ord( @$Str[ 1 ] ) === 187 && ord( @$Str[ 2 ] ) === 191 )
{
$Str = substr( $Str , 3 );
}
}
return( $Str );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
trim_common_prefix ( $Strings,
  $CommonPrefix = false 
)

Trimming common prefix.

Parameters
$Strings- Strings to process.
CommonPrefix- Trimming prefix.
Returns
Processed string.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 235 of file text.php.

{
try
{
if( $CommonPrefix === false )
{
$CommonPrefix = $this->common_prefix( $Strings );
}
if( $CommonPrefix !== '' )
{
foreach( $Strings as $i => $String )
{
$Strings[ $i ] = str_replace( $CommonPrefix , '' , $String );
}
}
return( $Strings );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Field Documentation

$KOIPatternL = '~([\243])|([\300-\307])|([\310-\317])|([\320-\327])|([\330-\337])~s'

Charset patterns

Author
Dodonov A.A.

Definition at line 294 of file text.php.

$KOIPatternU = '~([\263])|([\340-\347])|([\350-\357])|([\360-\367])|([\370-\377])~s'

Charset patterns

Author
Dodonov A.A.

Definition at line 306 of file text.php.

$Patterns = array()

Charset patterns.

Author
Dodonov A.A.

Definition at line 318 of file text.php.

$Tags = false

Cached objects.

Author
Dodonov A.A.

Definition at line 38 of file text.php.

$WINPatternL = '~([\270])|([\340-\347])|([\350-\357])|([\360-\367])|([\370-\377])~s'

Charset patterns

Author
Dodonov A.A.

Definition at line 270 of file text.php.

$WINPatternU = '~([\250])|([\300-\307])|([\310-\317])|([\320-\327])|([\330-\337])~s'

Charset patterns

Author
Dodonov A.A.

Definition at line 282 of file text.php.


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