[Elements] are optional
Class SAPO.Utility.String
class
SAPO.Utility.String
String utility function
Defined in
Utility/String/0.1/lib.jsInclusion link: http://js.sapo.pt/SAPO/Utility/String/0.1/
Sample: http://js.sapo.pt/SAPO/Utility/String/sample/
Function Summary
Convert listed HTML entities to character
Convert listed characters to HTML entities
Convert all accented chars to char without accent.
Make a string shorter without cutting words
Count the number of occurrences of a specific needle in a haystack
Truncates a string, breaking words and adding ... at the end
Convert first letter of a word to upper case
If param as more than one word, it converts first letter of all words that have more than 2 letters
If param as more than one word, it converts first letter of all words that have more than 2 letters
Decode a string from UTF8
utf8Encode
(String
string)
Encode a string to UTF8
Function Details
function evalJSON
eval a JSON string to a JS object
Parameters:
JSON
Returns:
object JS Object
function htmlEntitiesDecode
Convert listed HTML entities to character
Parameters:
string
Returns:
string decoded
function htmlEntitiesEncode
Convert listed characters to HTML entities
Parameters:
string
Returns:
string encoded
function removeAccentedChars
Convert all accented chars to char without accent.
Parameters:
string
Returns:
string without accented chars
function shortString
Make a string shorter without cutting words
Parameters:
str
n
- number of chars of the short string
Returns:
string shorted
function stripTags
Remove HTML tags of string
Parameters:
string
[strip]
tagNames separated by comma ","
Returns:
without HTML tag
var myvar='isto e um texto bold com imagem
e br
um
um
paragrafo
'; SAPO.Utility.String.stripTags(myvar, 'b,u');function substrCount
Count the number of occurrences of a specific needle in a haystack
Parameters:
haystack
needle
Returns:
int with number of occurrences
function trim
Remove spaces and new line from biggin and ends of string
Parameters:
string
Returns:
string trimmed
function truncateString
Truncates a string, breaking words and adding ... at the end
Parameters:
str
l
- limit for the string
Returns:
short string
function ucFirst
Convert first letter of a word to upper case
If param as more than one word, it converts first letter of all words that have more than 2 letters
If param as more than one word, it converts first letter of all words that have more than 2 letters
Parameters:
string
Returns:
{String} string camel case
function utf8Decode
Decode a string from UTF8
Parameters:
string
Returns:
string utf8 decoded
function utf8Encode
utf8Encode(String
string)
Encode a string to UTF8
Parameters:
string
Returns:
{String} string utf8 encoded