From cedd425f074deae961b0eae8a0db2724357a7155 Mon Sep 17 00:00:00 2001
From: Ioannis Brant-Ioannidis <72696535+gbrandtio@users.noreply.github.com>
Date: Sat, 25 Mar 2023 22:05:53 +0400
Subject: [PATCH 1/3] Adding test workflow badge on README
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index 7f2f228..3d1bf17 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,7 @@

+
From b131b472414455bdf674ddc7f3b816182fd19507 Mon Sep 17 00:00:00 2001
From: Ioannis Brant-Ioannidis
Date: Sun, 26 Mar 2023 00:17:21 +0400
Subject: [PATCH 2/3] Replace common symbols with letters
Added support for replacement of common issues with letters, which was proposed on #23.
---
lib/string_extensions.dart | 57 ++++++++++++++++++++++++++++++++
lib/string_helpers.dart | 11 +++++-
test/string_extensions_test.dart | 7 ++++
3 files changed, 74 insertions(+), 1 deletion(-)
diff --git a/lib/string_extensions.dart b/lib/string_extensions.dart
index ad7749b..0190ef5 100644
--- a/lib/string_extensions.dart
+++ b/lib/string_extensions.dart
@@ -2499,4 +2499,61 @@ extension MiscExtensions on String? {
}
return this!.toUpperCase() != this && this!.toLowerCase() != this;
}
+
+ /// Transforms the symbols of a string to their equivalent letters.
+ ///
+ /// It offers support for both English and Greek strings. For Greek strings
+ /// currently there is no support for accented letters.
+ /// For example:
+ /// ```
+ /// Th!s !s just @ t#st
+ /// ```
+ /// will produce:
+ /// ```
+ /// This is just a test
+ /// ```
+ /// Equivalently in Greek:
+ /// ```
+ /// Αυτό #ίναι #ν@ τ#στ
+ /// ```
+ /// will produce:
+ /// ```
+ /// Αυτό είναι ενα τεστ
+ /// ```
+ String? get symbolsToLetters {
+ bool containsAnyGreekCharacter = this.containsAnyGreekCharacter;
+ List characters = this.toArray;
+
+ List validGreekSymbols =
+ StringHelpers.greekSymbolsToLetters.keys.toList();
+ List validEnglishSymbols =
+ StringHelpers.englishSymbolsToLetters.keys.toList();
+
+ for (int i = 0; i < characters.length; i++) {
+ switch (containsAnyGreekCharacter) {
+ case true:
+ characters[i] = replaceSymbolWithLetter(characters[i],
+ validGreekSymbols, StringHelpers.greekSymbolsToLetters);
+ break;
+ default:
+ characters[i] = replaceSymbolWithLetter(characters[i],
+ validEnglishSymbols, StringHelpers.englishSymbolsToLetters);
+ break;
+ }
+ }
+
+ return characters.join("");
+ }
+
+ /// Replaces the [symbol] with it's equivalent value in the [mapOfSymbolsToLetters]
+ /// if it exists on the [validSymbols] list.
+ String replaceSymbolWithLetter(String? symbol, List validSymbols,
+ Map mapOfSymbolsToLetters) {
+ String letter = symbol!;
+ if (validSymbols.contains(symbol)) {
+ letter = mapOfSymbolsToLetters[symbol]!;
+ }
+
+ return letter;
+ }
}
diff --git a/lib/string_helpers.dart b/lib/string_helpers.dart
index 4584009..4d7be3d 100644
--- a/lib/string_helpers.dart
+++ b/lib/string_helpers.dart
@@ -311,6 +311,7 @@ class StringHelpers {
"Χ",
"X"
];
+
static Map greekToLatin = {
'ά': 'a',
'Α': 'a',
@@ -384,11 +385,19 @@ class StringHelpers {
'ώ': 'o',
};
- static Map lettersToSymbols = {
+ static Map englishSymbolsToLetters = {
' ': ' ',
'!': 'i',
'@': 'a',
'\$': 's',
'#': 'e'
};
+
+ static Map greekSymbolsToLetters = {
+ ' ': ' ',
+ '!': 'ι',
+ '@': 'α',
+ '\$': 'σ',
+ '#': 'ε'
+ };
}
diff --git a/test/string_extensions_test.dart b/test/string_extensions_test.dart
index 865cba7..4354a13 100644
--- a/test/string_extensions_test.dart
+++ b/test/string_extensions_test.dart
@@ -1412,4 +1412,11 @@ void main() {
expect("HELLOworld!".isMixedCase(), equals(true));
expect("HelloWORLD!".isMixedCase(), equals(true));
});
+
+ test("Replaces the symbols of a string to their equivalent letters", () {
+ expect(
+ "Th!s !s just @ t#st".symbolsToLetters, equals("This is just a test"));
+ expect(
+ "Αυτό #ίναι #ν@ τ#στ".symbolsToLetters, equals("Αυτό είναι ενα τεστ"));
+ });
}
From 9747e89833f94416f4e68431a3df49fb8b485394 Mon Sep 17 00:00:00 2001
From: Ioannis Brant-Ioannidis
Date: Sun, 26 Mar 2023 01:30:53 +0400
Subject: [PATCH 3/3] Reverting commits added for #23
As per PR comments, there are additional symbols/functionality required for this implementation for which a reference can be found at https://en.wikipedia.org/wiki/Leet.
---
lib/string_extensions.dart | 57 --------------------------------
lib/string_helpers.dart | 16 ---------
test/string_extensions_test.dart | 7 ----
3 files changed, 80 deletions(-)
diff --git a/lib/string_extensions.dart b/lib/string_extensions.dart
index 0190ef5..ad7749b 100644
--- a/lib/string_extensions.dart
+++ b/lib/string_extensions.dart
@@ -2499,61 +2499,4 @@ extension MiscExtensions on String? {
}
return this!.toUpperCase() != this && this!.toLowerCase() != this;
}
-
- /// Transforms the symbols of a string to their equivalent letters.
- ///
- /// It offers support for both English and Greek strings. For Greek strings
- /// currently there is no support for accented letters.
- /// For example:
- /// ```
- /// Th!s !s just @ t#st
- /// ```
- /// will produce:
- /// ```
- /// This is just a test
- /// ```
- /// Equivalently in Greek:
- /// ```
- /// Αυτό #ίναι #ν@ τ#στ
- /// ```
- /// will produce:
- /// ```
- /// Αυτό είναι ενα τεστ
- /// ```
- String? get symbolsToLetters {
- bool containsAnyGreekCharacter = this.containsAnyGreekCharacter;
- List characters = this.toArray;
-
- List validGreekSymbols =
- StringHelpers.greekSymbolsToLetters.keys.toList();
- List validEnglishSymbols =
- StringHelpers.englishSymbolsToLetters.keys.toList();
-
- for (int i = 0; i < characters.length; i++) {
- switch (containsAnyGreekCharacter) {
- case true:
- characters[i] = replaceSymbolWithLetter(characters[i],
- validGreekSymbols, StringHelpers.greekSymbolsToLetters);
- break;
- default:
- characters[i] = replaceSymbolWithLetter(characters[i],
- validEnglishSymbols, StringHelpers.englishSymbolsToLetters);
- break;
- }
- }
-
- return characters.join("");
- }
-
- /// Replaces the [symbol] with it's equivalent value in the [mapOfSymbolsToLetters]
- /// if it exists on the [validSymbols] list.
- String replaceSymbolWithLetter(String? symbol, List validSymbols,
- Map mapOfSymbolsToLetters) {
- String letter = symbol!;
- if (validSymbols.contains(symbol)) {
- letter = mapOfSymbolsToLetters[symbol]!;
- }
-
- return letter;
- }
}
diff --git a/lib/string_helpers.dart b/lib/string_helpers.dart
index 4d7be3d..ecaa8dc 100644
--- a/lib/string_helpers.dart
+++ b/lib/string_helpers.dart
@@ -384,20 +384,4 @@ class StringHelpers {
'Ώ': 'o',
'ώ': 'o',
};
-
- static Map englishSymbolsToLetters = {
- ' ': ' ',
- '!': 'i',
- '@': 'a',
- '\$': 's',
- '#': 'e'
- };
-
- static Map greekSymbolsToLetters = {
- ' ': ' ',
- '!': 'ι',
- '@': 'α',
- '\$': 'σ',
- '#': 'ε'
- };
}
diff --git a/test/string_extensions_test.dart b/test/string_extensions_test.dart
index 4354a13..865cba7 100644
--- a/test/string_extensions_test.dart
+++ b/test/string_extensions_test.dart
@@ -1412,11 +1412,4 @@ void main() {
expect("HELLOworld!".isMixedCase(), equals(true));
expect("HelloWORLD!".isMixedCase(), equals(true));
});
-
- test("Replaces the symbols of a string to their equivalent letters", () {
- expect(
- "Th!s !s just @ t#st".symbolsToLetters, equals("This is just a test"));
- expect(
- "Αυτό #ίναι #ν@ τ#στ".symbolsToLetters, equals("Αυτό είναι ενα τεστ"));
- });
}