mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-11-30 22:02:57 -08:00
Remove diacritical marks in search string #945
This commit is contained in:
1 parent
01b7d28154
commit
384993d363
5 files changed
+16
-3
No files matched your search
@@ -30,6 +30,7 @@ import com.kunzisoft.keepass.model.EntryInfo
|
||||
import com.kunzisoft.keepass.model.SearchInfo
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.timeout.TimeoutHelper
|
||||
import com.kunzisoft.keepass.utils.StringUtil.removeDiacriticalMarks
|
||||
|
||||
class SearchHelper {
|
||||
|
||||
@@ -134,7 +135,9 @@ class SearchHelper {
|
||||
while (it.hasNext()) {
|
||||
val currentString = it.next()
|
||||
if (currentString.isNotEmpty()
|
||||
&& currentString.contains(searchQuery, true)) {
|
||||
&& currentString
|
||||
.removeDiacriticalMarks()
|
||||
.contains(searchQuery.removeDiacriticalMarks(), true)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.kunzisoft.keepass.utils
|
||||
|
||||
import java.text.Normalizer
|
||||
|
||||
object StringUtil {
|
||||
|
||||
fun String.removeLineChars(): String {
|
||||
@@ -10,5 +12,10 @@ object StringUtil {
|
||||
return this.replace("[\\r|\\n|\\t|\\s|\\u00A0]+".toRegex(), "")
|
||||
}
|
||||
|
||||
fun String.removeDiacriticalMarks(): String {
|
||||
return "\\p{InCombiningDiacriticalMarks}+".toRegex()
|
||||
.replace(Normalizer.normalize(this, Normalizer.Form.NFD), "")
|
||||
}
|
||||
|
||||
fun ByteArray.toHexString() = joinToString("") { "%02X".format(it) }
|
||||
}
|
||||
Reference in new issue
Block a user