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.native.js 783B

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