2016-10-10 03:43:44 +02:00
|
|
|
/** Used to compose unicode character classes. */
|
|
|
|
var rsAstralRange = '\\ud800-\\udfff',
|
2016-11-16 01:59:39 +01:00
|
|
|
rsComboMarksRange = '\\u0300-\\u036f',
|
|
|
|
reComboHalfMarksRange = '\\ufe20-\\ufe2f',
|
|
|
|
rsComboSymbolsRange = '\\u20d0-\\u20ff',
|
|
|
|
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
|
2016-10-10 03:43:44 +02:00
|
|
|
rsVarRange = '\\ufe0e\\ufe0f';
|
|
|
|
|
|
|
|
/** Used to compose unicode capture groups. */
|
|
|
|
var rsZWJ = '\\u200d';
|
|
|
|
|
|
|
|
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
|
2016-11-16 01:59:39 +01:00
|
|
|
var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if `string` contains Unicode symbols.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param {string} string The string to inspect.
|
|
|
|
* @returns {boolean} Returns `true` if a symbol is found, else `false`.
|
|
|
|
*/
|
|
|
|
function hasUnicode(string) {
|
|
|
|
return reHasUnicode.test(string);
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = hasUnicode;
|