Added support for prosigns and a few more characters.

This commit is contained in:
jeremiah 2013-05-28 13:33:22 -07:00
parent 8e3e24de75
commit 0de0e9ac21
2 changed files with 35 additions and 4 deletions

View file

@ -48,10 +48,29 @@ namespace CWLibrary
{ ".", ".-.-.-" },
{ ",", "--..--" },
{ "?", "..--.." },
{ "'", ".----." },
{ "/", "-..-." },
{ "<AR>", ".-.-." },
{ "<BK>", "-...-.-" },
{ "<SK>", "...-.-" }
{ "(", "-.--." },
{ ")", "-.--.-" },
{ ":", "---..." },
{ ";", "-.-.-." },
{ "=", "-...-" },
{ "+", ".-.-." },
{ "-", "-....-" },
{ "\"", ".-..-." },
{ "@", ".--.-." },
// Prosigns -- see
// http://en.wikipedia.org/wiki/Prosigns_for_Morse_code
{ "<aa>", ".-.-" }, // Space down one line (new line)
{ "<ar>", ".-.-." }, // Stop copying (end of message)
{ "<as>", ".-..." }, // Stand by
{ "<bk>", "-...-.-" }, // Break
{ "<bt>", "-...-" }, // Space down two lines
{ "<cl>", "-.-..-.." }, // Clear (going off the air)
{ "<ct>", "-.-.-" }, // Start copying
{ "<kn>", "-.--." }, // Go only
{ "<sk>", "...-.-" }, // Silent key (going off the air)
{ "<sn>", "...-." } // Understood
};
}
}

View file

@ -126,7 +126,19 @@ namespace CWLibrary
{
if (i > 0)
data.AddRange(GetInterCharSpace());
data.AddRange(GetCharacter(word[i].ToString()));
if (word[i] == '<')
{
// Prosign
int end = word.IndexOf('>', i);
if (end < 0)
throw new ArgumentException();
data.AddRange(GetCharacter(word.Substring(i, end + 1 - i)));
i = end;
}
else
{
data.AddRange(GetCharacter(word[i].ToString()));
}
}
return data.ToArray<short>();