You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

strings.web.js 662B

12345678910111213141516171819202122
  1. // @flow
  2. /**
  3. * Applies NFKC normalization to the given text.
  4. *
  5. * @param {string} text - The text that needs to be normalized.
  6. * @returns {string} - The normalized text.
  7. */
  8. export function normalizeNFKC(text: string) {
  9. return text.normalize('NFKC');
  10. }
  11. /**
  12. * Replaces accent characters with english alphabet characters.
  13. * NOTE: Here we use the unorm package because the JSC version in React Native for Android crashes.
  14. *
  15. * @param {string} text - The text that needs to be normalized.
  16. * @returns {string} - The normalized text.
  17. */
  18. export function normalizeAccents(text: string) {
  19. return text.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
  20. }