Skip to main content

Easily and correctly encode and decode text into Morse code

Project description

MorseCodePy


Introduction

MorseCodePy is a versatile Python module that streamlines the encoding and decoding of text into Morse code and back. With support for multiple languages, including English, Russian, Spanish, French, as well as provisions for handling numbers and special characters, this module offers a powerful and user-friendly Morse code tool. Whether you want to send messages, decipher existing ones, or simply explore the world of Morse code, MorseCodePy has you covered.


How to Use

encode(string, language, dot, dash, error)

Encode a text string into Morse code.

  • string: The text string you want to encode.
  • language: The target language for encoding (e.g., Language.english, Language.french, Language.numbers).
  • dot: (Optional) Symbol to represent dots (default is .).
  • dash: (Optional) Symbol to represent dashes (default is -).
  • error: (Optional) Symbol to represent errors when an unknown character is encountered (default is *).
from MorseCodePy import encode, Language

encoded_string = encode('Hello, world!', language=Language.english)
print(encoded_string)
# Output: .... . .-.. .-.. --- --..-- / .-- --- .-. .-.. -.. -.-.--

decode(string, language, dot, dash, error)

Decode Morse code into a text string.

  • string: The Morse code string you want to decode.
  • language: The target language for decoding (e.g., Language.russian, Language.spanish, Language.special).
  • dot: (Optional) Symbol to represent dots (default is .).
  • dash: (Optional) Symbol to represent dashes (default is -).
  • error: (Optional) Symbol to represent errors when an unknown Morse code sequence is encountered (default is *).
from MorseCodePy import decode, Language

decoded_string = decode('···· · ·-·· ·-·· --- --··-- / ·-- --- ·-· ·-·· -·· -·-·--', language=Language.english, dot='·')
print(decoded_string)
# Output: hello, world!

Language

The Language enumeration represents different languages, including special cases for numbers and special characters. Use it to specify the language when encoding or decoding Morse code.

Supported languages include Language.english, Language.spanish, Language.french, Language.russian, Language.ukrainian, as well as special categories for handling Language.numbers and Language.special.


encodes and decodes

These dictionaries contain Morse code representations for various languages and characters. You can access these dictionaries to customize the encoding and decoding behavior.

import MorseCodePy as mcp

english_encoding = mcp.encodes[mcp.Language.english]
russian_decoding = mcp.decodes[mcp.Language.russian]

Explore and adapt this Morse code tool for your specific needs.


Licence

This project is licensed under the MIT License. See the licence file for more details.


Contact

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

MorseCodePy-2.0.1.tar.gz (5.0 kB view details)

Uploaded Source

File details

Details for the file MorseCodePy-2.0.1.tar.gz.

File metadata

  • Download URL: MorseCodePy-2.0.1.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for MorseCodePy-2.0.1.tar.gz
Algorithm Hash digest
SHA256 c43e6a0f7bca8f9f063d352a7a40f1476ab6ef2d3bc6d6aec7cfef360f665f99
MD5 268467927278b59155ffa4611da432d2
BLAKE2b-256 64dd9dcae367a4a09e6a1588af6849abbccb34340863b128d537ac2554606610

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page