| 367 | |
| 368 | // Adapted from: https://mathiasbynens.be/notes/javascript-unicode |
| 369 | countSymbols(string) { |
| 370 | let index; |
| 371 | let symbolCount = 0; |
| 372 | for (index = 0; index < string.length - 1; ++index) { |
| 373 | var charCode = string.charCodeAt(index); |
| 374 | if (charCode >= 0xD800 && charCode <= 0xDBFF) { |
| 375 | charCode = string.charCodeAt(index + 1); |
| 376 | if (charCode >= 0xDC00 && charCode <= 0xDFFF) { |
| 377 | index++; |
| 378 | symbolCount++; |
| 379 | continue; |
| 380 | } |
| 381 | } |
| 382 | symbolCount++; |
| 383 | } |
| 384 | if (string.charAt(index) !== "") { |
| 385 | symbolCount++; |
| 386 | } |
| 387 | return symbolCount; |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | //--------------------------------------------------------------------- |