Package DE_EPAGES::Core::API::String
String manipulation functions
Functions
- CompareStrings
- ConvertNewlines
- DecodeStructure
- EncodeNonISO1Chars
- EncodeStructure
- GetWordCount
- QuoteTags
- QuoteXML
- UnquoteXML
CompareStrings
Compare two given strings and return how much they are similar. Uses
word based levenshtein comparison ratio.
The $Coverage parameter defines how similar two words have to be to be
rated as equal or as different. The Default value is 0.8 (80%).
The returned $Percentage value is a float number between 0 and 1.0 which
tells how similar the both supplied strings are.
Syntax |
$Percentage = CompareStrings($StringA, $StringB)
|
Input |
- $StringA (string)
- first string
- $StringB (string)
- second string
- $Coverage (float)
- Coverage value for similarity check [0..1]. Default: 0.8 (optional)
|
Return |
- $Percentage (float)
- ratio how similar the strings are [0..1]
|
ConvertNewlines
replace white spaces including newlines with a single space.
Syntax |
$OneLineString = ConvertNewlines($StringWithNewlines)
|
Input |
- $Value (string)
- string containing new lines
|
Return |
- $Value (string)
- one-lined string
|
DecodeStructure
Decodes all strings in a nestes array/hash structure with a given
character encoding. The function creates a copy of the structure. The
original structure is not changed.
Syntax |
$Structure = DecodeStructure( $Encoding, $EncodedStructure )
|
Example |
$Structure = DecodeStructure( 'iso-8859-1', $EncodedStructure );
|
Input |
- $Encoding (string)
- character encoding, example: 'iso-8859-1'
- $EncodedStructure (ref)
- the structure with encoded strings
|
Return |
- $Structure (ref)
- a tree structure of arrays and/or hashes
|
EncodeNonISO1Chars
Syntax |
$Output = EncodeNonISO1Chars( $Input );
|
Example |
"&
|
EncodeStructure
Encodes all strings in a nestes array/hash structure with a given
character encoding. The function creates a copy of the structure. The
original structure is not changed.
Syntax |
$EncodedStructure = EncodeStructure( $Encoding, $Structure )
|
Example |
$EncodedStructure = EncodeStructure( 'iso-8859-1', \%Structure );
|
Input |
- $Encoding (string)
- character encoding, example: 'iso-8859-1'
- $Structure (ref)
- a tree structure of arrays and/or hashes
|
Return |
- $EncodedStructure (ref)
- the structure with encoded strings
|
GetWordCount
Returns the number of words found in a given string.
Syntax |
$Count = GetWordCount($String)
|
Input |
- $String (string)
- text string
|
Return |
- $Count (integer)
- number of words
|
QuoteTags
Replaces the special characters <and> by < and > respectively.
Syntax |
$Output = QuoteTags( $Input );
|
Example |
print QuoteTags( "<bigger>&</bigger>" );
|
Input |
- $Input (string)
- input string
|
Return |
- $Output (string)
- output string
|
QuoteXML
Replaces the special characters &"' by their corresponding XML entities.
Syntax |
$Output = QuoteXML( $Input );
|
Example |
print QuoteXML( "<bigger>&</bigger>" );
|
Input |
- $Input (string)
- input string
|
Return |
- $Output (string)
- output string
|
UnquoteXML
Replaces standard XML entities by the corresponding special characters.
Syntax |
$Output = UnquoteXML( $Input );
|
Input |
- $Input (string)
- input string
|
Return |
- $Output (string)
- output string
|