Last change
on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
949 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | /** Used to compose unicode character classes. */
|
---|
| 2 | var rsAstralRange = '\\ud800-\\udfff',
|
---|
| 3 | rsComboMarksRange = '\\u0300-\\u036f',
|
---|
| 4 | reComboHalfMarksRange = '\\ufe20-\\ufe2f',
|
---|
| 5 | rsComboSymbolsRange = '\\u20d0-\\u20ff',
|
---|
| 6 | rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
|
---|
| 7 | rsVarRange = '\\ufe0e\\ufe0f';
|
---|
| 8 |
|
---|
| 9 | /** Used to compose unicode capture groups. */
|
---|
| 10 | var rsZWJ = '\\u200d';
|
---|
| 11 |
|
---|
| 12 | /** 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/). */
|
---|
| 13 | var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
|
---|
| 14 |
|
---|
| 15 | /**
|
---|
| 16 | * Checks if `string` contains Unicode symbols.
|
---|
| 17 | *
|
---|
| 18 | * @private
|
---|
| 19 | * @param {string} string The string to inspect.
|
---|
| 20 | * @returns {boolean} Returns `true` if a symbol is found, else `false`.
|
---|
| 21 | */
|
---|
| 22 | function hasUnicode(string) {
|
---|
| 23 | return reHasUnicode.test(string);
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | module.exports = hasUnicode;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.