String

Extensions to the standard JavaScript String class to add behavior.

Remarks

The following methods have been added by the framework to the String prototype, to provide more consistency or improved functionality.

Methods

appendUtf8Appends the UTF-8 escaped version of this string to the text array.
trimRemoves any whitespace from the start or end of the string.

String appendUtf8 method

Appends the UTF-8 escaped version of this string to the text array.

JavaScript

string.appendUtf8(textArray)

Remarks

This follows the JavaScript escape rules to append one or more strings to textArray, representing this string but with all special characters escaped. The following character escape rules are used:

Char CodeEscaped Value
0x08\b
0x09\t
0x0a\n
0x0c\f
0x0d\r
0x22\"
0x5c\\
0x5c\\
0xa0 to 0xff\xXX (two hex digits)
0x100 to 0xffff\uXXXX (four hex digits)

Example

// newline, copyright, pi
var str="chrs: \n\xA9\u03c0";
var textArray = new Array();
str.appendUtf8(textArray);
// textArray now contains four strings 'chrs: ', '\n', '\u00a9', '\u03c0'.
// use Array.join('') to turn this back into a string, e.g.
alert(str + ' = ' + textArray.join(''));

String trim method

Removes any whitespace from the start or end of the string.

JavaScript

string.trim()