Make string methods work with latin-1 characters by default.

This commit is contained in:
John-David Dalton
2014-09-10 21:40:27 -07:00
parent 678321bb2f
commit 1fe9ba5879
2 changed files with 12 additions and 6 deletions

View File

@@ -99,7 +99,13 @@
var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
/** Used to match words to create compound words */
var reWords = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*)|[A-Z]?[a-z]+[0-9]*|[A-Z]+|[0-9]+/g;
var reWords = (function() {
var nums = '[0-9]',
upper = '[A-Z\\xC0-\\xD6\\xD8-\\xDE]',
lower = '[a-z\\xDF-\\xF6\\xF8-\\xFF]+' + nums + '*';
return RegExp(upper + '{2,}(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|' + nums + '+', 'g');
}());
/** Used to detect and test whitespace */
var whitespace = (
@@ -8773,7 +8779,7 @@
* // => ['fred', 'barney', '&', 'pebbles']
*/
function words(string, pattern) {
string = string == null ? '' : String(string);
string = string != null && String(string);
return (string && string.match(pattern || reWords)) || [];
}

View File

@@ -1320,7 +1320,7 @@
return func(string) === expected;
});
ok(_.every(actual));
deepEqual(actual, _.map(strings, _.constant(true)));
});
test('`_.' + methodName + '` should handle double-converting strings', 1, function() {
@@ -1328,15 +1328,15 @@
return func(func(string)) === expected;
});
ok(_.every(actual));
deepEqual(actual, _.map(strings, _.constant(true)));
});
test('`_.' + methodName + '` should deburr letters', 1, function() {
var actual = _.map(burredLetters, function(burred, index) {
return func(burred) == deburredLetters[index].toLowerCase();
return func(burred) === deburredLetters[index].toLowerCase();
});
ok(_.every(actual));
deepEqual(actual, _.map(burredLetters, _.constant(true)));
});
test('`_.' + methodName + '` should coerce `string` to a string', 2, function() {