Morse code (also translated into Morse code, Morse code) is a time-pass time-broken signal codes, in different order to express different English letters, numbers and punctuation. It was invented by the American Elfid Ville in 1837. Morse code is an early form of digital communication, but it differs from modern binary codes that use only 0 and one or two states, and its codes include five kinds: points, strokes, pauses between points and strokes, short pauses between characters (between points and strokes), medium pauses between words, and long pauses between sentences.
Note that you can only use ASCII encoding 127 in the English/digital text and
Unicode is not supported but you can modify a portion of it yourself to support Unicode
Example code:
public static class Morsecode//Morse code (Interstellar traversal) {private static volatile string[,] codetable = { {"A", ".-"}, {"B", "-..."}, {"C", "-.-."}, {"D", "-.."}, {"E", "."}, {"E", ".. -.. "}, {" F ",".. -. "}, {" G ","--. "}, {" H "," ... "}, {" I "," ... "}, {" J ",".---"}, {" K ","-.-"}, {" L ",".-.. "}, {" M ","--"}, {" N ","-. "}, {" O ","---"}, { "P", ".--."}, {"Q", "--.-"}, {"R", ".-."}, {"S", "..."}, {"T", "-"}, {"U", ".. -"}, {" V "," ...-"}, {" W ",".--"}, {" X ","-.. -"}, {" Y ","-.--"}, {" Z ","--.. "}, {" 0 ","-----"}, {" 1 ",".----"}, {"2", ".. ---"}, {" 3 "," ...-"}, {" 4 "," ....-"}, {" 5 "," ... "}, {" 6 ","-.... "}, {"7", "--..."}, {"8", "---.."}, {"9", "----."}, {".", ".-.-.-"}, {",", "--.. --"}, {":","---..."}, {"?",".. --.."}, {"\'",".----."}, {"-","-....-"}, {"/","-.. -."}, {"(","-.--."}, {")","-.--.-"}, {"\"",".-.. -."}, {"=","-...-"}, {"+",".-.-."}, {"*","-.. -"}, {" @ ",".--.-. "}, {" {understood} "," ...-. "}, {" {ERROR} "," ... "}, {" { Invitation to transmit} ","-.-"}, {" {WAIT} ",".-... "}, {" {END of work} "," ...-.-"}, {" {ST Arting SIGNAL} ","-.-.-"}, {" "," \u2423 "}}; public static string Enc (String str) {int i; string ret = string. Empty; if (str! = null && (str = str). ToUpper ()). Length > 0) foreach (char asc in STR) if ((I= Find (ASC. ToString (), 0)) >-1) ret + = "" + codetable[i, 1]; return ret; } public static string Dec (String str) {int i; String[] splits; string ret = string. Empty; if (str! = NULL && (splits = str. Split (')). Length > 0) {foreach (string split in splits) if ((i = Find (split, 1)) >-1) ret + = codetable[i, 0]; return ret; } return "{#}"; } private static int Find (string str, int cols) {int i = 0, Len = codetable.length/ 2; Len/rank while (i < len) {if (codetable[i, cols] = = str) return i; i++; }; return-1; } }
Using code:
String encry = Morsecode.enc ("China"); Convert China to Morse code string decry = Morsecode.dec (encry);//convert encry to clear form