From 3f40401ca0c661c68fb620274790cccf5ed13d43 Mon Sep 17 00:00:00 2001 From: Lubomir Balogh <24496198+lubobalogh@users.noreply.github.com> Date: Wed, 13 Sep 2023 14:17:08 +0200 Subject: [PATCH] primefaces/primeng#10482 Fix removing diacritics --- src/app/components/utils/objectutils.ts | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/app/components/utils/objectutils.ts b/src/app/components/utils/objectutils.ts index ae5dbf6bf09..cd18dd1071f 100644 --- a/src/app/components/utils/objectutils.ts +++ b/src/app/components/utils/objectutils.ts @@ -134,29 +134,8 @@ export class ObjectUtils { } public static removeAccents(str) { - if (str && str.search(/[\xC0-\xFF]/g) > -1) { - str = str - .replace(/[\xC0-\xC5]/g, 'A') - .replace(/[\xC6]/g, 'AE') - .replace(/[\xC7]/g, 'C') - .replace(/[\xC8-\xCB]/g, 'E') - .replace(/[\xCC-\xCF]/g, 'I') - .replace(/[\xD0]/g, 'D') - .replace(/[\xD1]/g, 'N') - .replace(/[\xD2-\xD6\xD8]/g, 'O') - .replace(/[\xD9-\xDC]/g, 'U') - .replace(/[\xDD]/g, 'Y') - .replace(/[\xDE]/g, 'P') - .replace(/[\xE0-\xE5]/g, 'a') - .replace(/[\xE6]/g, 'ae') - .replace(/[\xE7]/g, 'c') - .replace(/[\xE8-\xEB]/g, 'e') - .replace(/[\xEC-\xEF]/g, 'i') - .replace(/[\xF1]/g, 'n') - .replace(/[\xF2-\xF6\xF8]/g, 'o') - .replace(/[\xF9-\xFC]/g, 'u') - .replace(/[\xFE]/g, 'p') - .replace(/[\xFD\xFF]/g, 'y'); + if (str) { + str = str.normalize('NFKD').replace(/\p{Diacritic}/gu, ''); } return str;