Skip to main content

JS_SPACE

Constant JS_SPACE 

Source
pub const JS_SPACE: &str = "\t\n\u{b}\u{c}\r \u{a0}\u{1680}\u{2000}-\u{200a}\
                        \u{2028}\u{2029}\u{202f}\u{205f}\u{3000}\u{feff}";
Expand description

ECMA-262 WhiteSpace plus LineTerminator, which is what a JavaScript \s matches and what String.prototype.trim removes.

Rust does not agree with either. char::is_whitespace is the Unicode White_Space property, which HAS U+0085 and has NOT U+FEFF, and the regex crate reads \s the same way. ECMA-262 is the reverse: a byte-order mark is white space and a next-line control is not. Both characters reach this crate as ordinary element content, and each changes a trimmed value, so the class is written out once here and used by js_trim, js_parse_int and the author pattern.

The value is a regex character-class BODY, so it goes inside brackets: [JS_SPACE] is the JavaScript \s and [^JS_SPACE] is \S.