quote method
Implementation
String quote(String s) {
String q = String.fromCharCode(34);
String bs = String.fromCharCode(92);
int total = s.length;
String out = q;
int start = 0;
int k = 0;
while (k < total) {
int c = s.codeUnitAt(k);
if ( (c == 34 || c == 92) || ((c == 10 || c == 13) || c == 9) ) {
if ( k > start ) {
out = out + s.substring(start, k );
}
if ( c == 34 ) {
out = (out + bs) + q;
}
if ( c == 92 ) {
out = (out + bs) + bs;
}
if ( c == 10 ) {
out = (out + bs) + "n";
}
if ( c == 13 ) {
out = (out + bs) + "r";
}
if ( c == 9 ) {
out = (out + bs) + "t";
}
start = k + 1;
}
k = k + 1;
}
if ( total > start ) {
out = out + s.substring(start, total );
}
return out + q;
}