@technobuddha/library
Version:
A large library of useful functions
13 lines (12 loc) • 379 B
JavaScript
import { space } from '../constants';
/**
* Return the number of unicode code points in a string
*
* @param input the unicode string
* @returns the number of code points
*/
export function unicodeLength(input) {
// eslint-disable-next-line require-unicode-regexp
return input.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, space).length;
}
export default unicodeLength;