跳到主要内容
uencoder

如何Use Morse Code

编码 and decode text in Morse code for education and communication exercises.

问题

你需要转换文本到 Morse 代码或 解码 Morse 代码回 到文本.

前置条件

  • Knowledge 的 Morse 代码 symbols
  • Understanding 的 dots 和 dashes

步骤

  1. 1. Learn the Morse code mapping

    Each letter and digit maps to a sequence of dots (.) and dashes (-). A is .-, B is -..., etc. Letters are separated by a space, words by a larger gap (often represented as / or three spaces). Numbers and some punctuation also have mappings.

    输入
    HELLO
    输出
    .... . .-.. .-.. ---
  2. 2. Encode text to Morse

    Convert each character to its Morse sequence using the mapping. Separate letters with a single space and words with a slash or multiple spaces. Uppercase the input first, as Morse is case-insensitive. Unknown characters can be skipped or marked with a placeholder.

    输入
    SOS HELP
    输出
    ... --- ... / .... . .-.. .--.
  3. 3. Decode Morse to text

    Split the Morse string on word separators first, then on letter separators. Map each Morse sequence back to its character. Handle ambiguous separators: a single space separates letters, a slash or multiple spaces separates words.

    输入
    ... --- ...
    输出
    SOS

预期结果

正确 Morse 代码编码或 解码的 输入文本.

常见错误

Word boundaries lost in decoding
Use a clear word separator (like /) between words. A single space between letters and / between words is the common convention.
Lowercase letters not handled
Morse code is case-insensitive. Uppercase the input before encoding, and output uppercase when decoding.

排障指引

  • If decoding produces wrong characters, verify the Morse mapping table.
  • Ensure consistent use of separators: one space between letters, / or three spaces between words.

安全限制

  • Morse code is a simple substitution encoding with no security properties.

相关工具

参考链接