mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 16:17:50 +00:00
29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
/** Used to compose unicode character classes. */
|
|
const rsAstralRange = '\\ud800-\\udfff'
|
|
const rsComboMarksRange = '\\u0300-\\u036f'
|
|
const reComboHalfMarksRange = '\\ufe20-\\ufe2f'
|
|
const rsComboSymbolsRange = '\\u20d0-\\u20ff'
|
|
const rsComboMarksExtendedRange = '\\u1ab0-\\u1aff'
|
|
const rsComboMarksSupplementRange = '\\u1dc0-\\u1dff'
|
|
const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange + rsComboMarksExtendedRange + rsComboMarksSupplementRange
|
|
const rsVarRange = '\\ufe0e\\ufe0f'
|
|
|
|
/** Used to compose unicode capture groups. */
|
|
const 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/). */
|
|
const reHasUnicode = RegExp(`[${rsZWJ + rsAstralRange + rsComboRange + rsVarRange}]`)
|
|
|
|
/**
|
|
* 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)
|
|
}
|
|
|
|
export default hasUnicode
|