Module modCodecs
Private Function codecConvertion(ByVal str As String, _
ByVal toCode As Boolean, ByVal codec(,) As String) As String
str = str.Trim.ToLower
Dim a, b As Int16
If toCode Then
a = 0 : b = 1
Else
a = 1 : b = 0
End If
For x As Int16 = LBound(codec, 1) To UBound(codec, 1)
str = str.Replace(codec(x, a), codec(x, b))
Next
Return str
End Function
Public Function leetConvertion(ByVal leetStr As String, ByVal toLeet As Boolean) As String
Dim leetCodec(,) As String = { _
{"leet", "31337"}, _
{"at", "@"}, _
{"love", "<3"}, _
{"lol", "1O!z"}, _
{"a", "4"}, _
{"b", "8"}, _
{"c", "["}, _
{"e", "3"}, _
{"h", "}{"}, _
{"i", "|"}, _
{"l", "1"}, _
{"o", "0"}, _
{"s", "5"}, _
{"t", "7"}, _
{"v", "\/"}, _
{"x", "*"}, _
{"v", "4"}, _
{" ", " "}}
Return codecConvertion(leetStr, toLeet, leetCodec)
End Function
Public Function morseConvertion(ByVal morseStr As String, ByVal toMorse As Boolean) As String
Dim morseCodec(,) As String = { _
{"?", "..-.../"}, _
{"_", "..-..-/"}, _
{".", ".-.-.-/"}, _
{"@", ".--.-./"}, _
{"'", ".----./"}, _
{"-", "-....-/"}, _
{";", "-.-.-./"}, _
{"!", "-.-.--/"}, _
{"(", "-.--../"}, _
{")", "-.--.-/"}, _
{",", "--..--/"}, _
{":", "---.../"}, _
{"0", "-----/"}, _
{"9", "----./"}, _
{"8", "---../"}, _
{"7", "--.../"}, _
{"6", "-..../"}, _
{"5", "...../"}, _
{"4", "....-/"}, _
{"3", "...--/"}, _
{"2", "..---/"}, _
{"1", ".----/"}, _
{"+", ".-.-./"}, _
{"=", "-...-/"}, _
{"ch", "----"}, _
{"h", "..../"}, _
{"v", "...-/"}, _
{"f", "..-./"}, _
{"u", "..--/"}, _
{"l", ".-../"}, _
{"a", ".-.-/"}, _
{"p", ".--./"}, _
{"j", ".---/"}, _
{"b", "-.../"}, _
{"x", "-..-/"}, _
{"c", "-.-./"}, _
{"y", "-.--/"}, _
{"z", "--../"}, _
{"q", "--.-/"}, _
{"o", "---./"}, _
{"s", ".../"}, _
{"u", "..-/"}, _
{"r", ".-./"}, _
{"w", ".--/"}, _
{"d", "-../"}, _
{"k", "-.-/"}, _
{"g", "--./"}, _
{"o", "---/"}, _
{"i", "../"}, _
{"a", ".-/"}, _
{"n", "-./"}, _
{"m", "--/"}, _
{"e", "./"}, _
{"t", "-/"}, _
{" ", "/"}}
Return codecConvertion(morseStr, toMorse, morseCodec)
End Function
End Module