Static Public Member Functions | |
String | doubleEscape (String s) |
replace all backslashes with two backslashes | |
String | quote (String str, Boolean escapeEOL, Boolean notIfIdent) |
produce a valid quoted string. | |
Boolean | endsWith (String s, String s2) |
Return true if s ends with s2. | |
Boolean | startsWith (String s, String s2) |
Return true if s starts with s2. | |
String | ltrim (String s) |
Trim any leading white space. | |
String | trim (String s) |
Trim leading and trailing white space TODO: compare speed of bu_trim* alternatives. | |
Boolean | isWhite (String s) |
Return true if s is false, empty, or entirely white space. | |
Array | splitTerms (String s, String tokenre) |
Split the string into an Array of terms. | |
String | unquote (String s) |
Remote any surrounding quotes (single or double). | |
String | ellipsis (String s, Number maxlen) |
If string length is less than or equal maxlen, return it. | |
Boolean | isDigit (String s) |
True if the given string is a digit char ([0-9]). | |
Boolean | isLetter (String s) |
True if the given string is a letter char ([a-zA-Z]). | |
String | zeroPad (Object s, Number len) |
Returns a String with enough leading zeros to make it a total length len. | |
String | spacePad (Object s, Number len, Boolean is_lj) |
space pad to length len. | |
Number | fprintf (Writer writer, String fmt,...) |
Formatted output to the Writer writer. | |
String | sprintf (String fmt,...) |
Return the sprintf result as a String. |
|
If string length is less than or equal maxlen, return it. Otherwise truncate string to maxlen and append '...' (so total length is maxlen + 3). |
|
Formatted output to the Writer writer. Supported flags: "0" zero padding right justify, such as "%0d" "-" left justify, such as "%-10s" " " blank for positive signed conversion, such as "% d" "+" sign for positive signed conversion, such as "%+d" "#" alternative form ("%#x") prepend '0' if necessary for 'o' prepend '0x' for 'x' and '0X' for 'X' ensure a decimal point for aAeEfgG do not remove trailing zeros for gG Unsupported flags: "'" use a thousands grouping character, if the locale says so (SUSv2 standard) Supported widths: "10" minimum field width (left justified if "%-10s") ".5" precision = for 'diouxX', minimum number of digits for zero padding, rest is space on left or right according to "-" flag for 'eEf', number of digits after decimal for 'gG', number of sig digits for either decimal or exponential notation for 's', maximum number of characters to truncate at Unsupported length modifiers (any of these): "h" short, "l" long "ll" long long "L" long double Supported conversion specifiers: s string c unsigned char bdiouxX int, various bases (b is non-standard, for base 2) eE double, exponential notation f double, decimal notation gG f or e according to exponent (f or E if "G") an escaped '%' Unsupported conversion specifiers: DOU long int aA double exponential hex notation p pointer n number of characters written so far stored in the argument Supported arguments: non-positional arguments ("%*s" or "%.*s" for width or precision) negative width value means lj; negative precision means unspecified Unsupported arguments: positional arguments ("%3$s" or "%*1$s" or "%.*2$s" for arg or width or precision) Returns number of characters written for fprintf, and the string for sprintf. CAVEATS: for 'uboxX' specifiers, we convert negative args to 32-bit unsigned by (0xffffffff + i + 1) we currently format double NaN and +-infinity as if they were 0 (pre-C99 convention) BUGS: the known unsupported items that are meaningful in JavaScript are positional arguments and thousands grouping TODO: would toLocaleString help with implementing SUSv2 ' radic? See also: Mavi Gozler (mavigozler@yahoo.com ) http://groups.google.com/groups?threadm=5446f761.0211181406.4a0388b0%40posting.google.com&rnum=8 Note that ECMAScript 262-3 has Number.toFixed(), Number.toExponential(), Number.toPrecision() These are not available in IE 5.0 PC or Safari1, but are implemented in fix_ecma.js. The implementation here relies on String.replace(searchValue, replaceValue) with replaceValue being a function. Many ECMAScript environments do not support this properly, despite it being standard. An implementation is available in fix_ecma.js. |
|
Trim any leading white space. Here "white space" means matching , which in EcmaScript means any white space or line terminator:
|
|
produce a valid quoted string. Internal quotes and backslashes are escaped with backslash. If escapeEOL is true, single character "\n" is converted to two characters. Remember that eval("\"\\\"").length == 1
|
|
space pad to length len.
|
|
Split the string into an Array of terms. A term is either an unquoted single-word token, or is a quoted string (single or double quotes). No white space is preserved except within quoted strings. The surrounding quotes on quoted terms are preserved. |
|
Returns a String with enough leading zeros to make it a total length len. If the input s is not a string it is made into one. |