API/libsapojs/SAPO/Utility/String

[Elements] are optional

Class SAPO.Utility.String


class SAPO.Utility.String
String utility function
Defined in Utility/String/0.1/lib.js

Function Summary
eval a JSON string to a JS object
Convert listed HTML entities to character
Convert listed characters to HTML entities
Convert all accented chars to char without accent.
String shortString (String str, Number n)
Make a string shorter without cutting words
String stripTags (String string, [String strip])
Remove HTML tags of string
String substrCount (String haystack, String needle)
Count the number of occurrences of a specific needle in a haystack
String trim (String string)
Remove spaces and new line from biggin and ends of string
String truncateString (String str, Number l)
Truncates a string, breaking words and adding ... at the end
String ucFirst (String string)
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
Decode a string from UTF8
utf8Encode (String string)
Encode a string to UTF8

Function Details

function evalJSON

String evalJSON(String JSON)
eval a JSON string to a JS object
Parameters:
JSON
Returns:
object JS Object

function htmlEntitiesDecode

String htmlEntitiesDecode(String string)
Convert listed HTML entities to character
Parameters:
string
Returns:
string decoded

function htmlEntitiesEncode

String htmlEntitiesEncode(String string)
Convert listed characters to HTML entities
Parameters:
string
Returns:
string encoded

function removeAccentedChars

String removeAccentedChars(String string)
Convert all accented chars to char without accent.
Parameters:
string
Returns:
string without accented chars

function shortString

String shortString(String str, Number n)
Make a string shorter without cutting words
Parameters:
str
n - number of chars of the short string
Returns:
string shorted

function stripTags

String stripTags(String string, [String strip])
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

paragrafo

'; SAPO.Utility.String.stripTags(myvar, 'b,u');

function substrCount

String substrCount(String haystack, String needle)
Count the number of occurrences of a specific needle in a haystack
Parameters:
haystack
needle
Returns:
int with number of occurrences

function trim

String trim(String string)
Remove spaces and new line from biggin and ends of string
Parameters:
string
Returns:
string trimmed

function truncateString

String truncateString(String str, Number l)
Truncates a string, breaking words and adding ... at the end
Parameters:
str
l - limit for the string
Returns:
short string

function ucFirst

String ucFirst(String string)
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
Parameters:
string
Returns:
{String} string camel case

function utf8Decode

String utf8Decode(String string)
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