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.ts 773B

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