String Javascript library

The String class provides means to manipulate arrays of chars (Strings)


1.4.1

New methods: join(), replace(), split().


int charAt (String s, int i):
Returns the ASCII/UTF-8 code of the character at index i inside string s.
Example:


String decodeBase64 (String s):
Return a string decoded in Base 64 from s.

Warning:
This method might not be available (requires MM.base64).

String decodeUrl (String s):
Returns an URL decoded version of the string s.
Example:


String encodeBase64 (String s):
Return a string encoded in Base 64 from s.

Warning:
This method might not be available (requires MM.base64).

String encodeUrl (String s):
Returns an URL encoded version of the string s.
Example:


bool endsWith (String s, String t):
Returns true if s ends with t.
Example:


int height (Node fontStyle):
Returns the height (in pixels) of the string rendered using the specified fontstyle node.

Warning:
The fontsyle node must not be switched !

int indexOf (String s, String char, int index):
Returns the first position of char in s, starting at index.
Example:


String join (MFString orig, char sep, int max):
Returns joined strings from orig using the optional sep char. Joining can be limited to the first max strings for orig.
Returns empty string on error.
Since 1.4.1

int lastIndexOf (String s, int char, int index):
Returns the last position of char in s, starting at index.
Example:


int length (String s):
Returns the number of chars in s.
Example:


String makeAscii (int i):
Returns a string with a single char made that has the parameter i as ascii code.
Example:


String replace (String s, String token, String replace):
Returns a string where all sub-strings matching token in s are replaced by the replace string.
Since 1.4.1

int split (string orig, MFString dest, [char separator]):
Split orig in tokens to fill the dest array.
If separator is not defined, comma ',' will be used as the default separator.
If no sep is found in orig, the first slot of dest will contain orig.
Returns the number of tokens or 0 on error.
Since 1.4.1

bool startsWith (String s, string t):
Returns true if s starts with t.
Example:


int strIndexOf (String s, String t, int index):
Returns the first position of t in s, starting at index.
Example:


String substring (String s, int start, int end):
Returns the substring of s, starting at start and ending at end.
If end < 0, return up to the end of the string.
Example:


float toFloat (String s):
Returns the float that can be converted from s.
Example:


int toInt (String s):
Returns the integer that can be converted from s.
Example:


String toLower (String s):
Returns the lower case version of s.
Example:


String toUpper (String s):
Returns the upper case version of s.
Example:


String trim (String s):
Returns the trimmed version of s (space removed at both ends).
Example:


int width (String s, Node fontStyle):
Returns the width (in pixels) of the string rendered using the specified fontstyle node.

Warning:
The fontsyle node must not be switched !

Warning:
The fontsyle node must be defined, otherwise the string itself is returned !