Morse

Introduction

Morse code, also known as Morse cipher, is a signal code that uses on-off tones to represent different English letters, numbers, and punctuation marks through different sequences.

Morse code is composed of two symbols: dot (.) and dash (-).

Implementation

Encoding

final Morse morseCoder = new Morse();

String text = "Hello World!";

// ...././.-../.-../---/-...../.--/---/.-./.-../-../-.-.--/
morseCoder.encode(text);

Decoding

String text = "你好,世界!";

// -..----.--...../-.--..-.-----.-/--------....--../-..---....-.--./---.-.-.-..--../--------.......-/
String morse = morseCoder.encode(text);

morseCoder.decode(morse);