bottom-cr
bottom-cr
A bottom spec implementation in Crystal
The spec can be found at https://github.com/bottom-software-foundation/spec
Installation
Just download bottom.cr and add it to your project or w/e
Usage
require "path/to/bottom.cr"
puts Bottom.encode("Hello")
# Output: 💖✨✨,,👉👈💖💖,👉👈💖💖🥺,,,👉👈💖💖🥺,,,👉👈💖💖✨,👉👈
puts Bottom.decode("💖✨✨,,👉👈💖💖,👉👈💖💖🥺,,,👉👈💖💖🥺,,,👉👈💖💖✨,👉👈")
# Output: Hello
Documentation
def decode(string : String) : String
Validates and decodes the given string. Raises an
ArgumentErrorif string is not a valid bottom-encoded string or the string is not valid a valid UTF8 string.Example:
Valid:
puts Bottom.decode("💖✨✨,,👉👈💖💖,👉👈💖💖🥺,,,👉👈💖💖🥺,,,👉👈💖💖✨,👉👈") # Output: HelloInvalid:
puts Bottom.decode("Hello") # Output: ArgumentErrorReturns
String
def encode(string : String) : String
Encodes string as per the bottom spec. Raises an
ArgumentErrorif the string is not a valid UTF8 string.Example:
puts Bottom.encode("Hello") # Output: 💖✨✨,,👉👈💖💖,👉👈💖💖🥺,,,👉👈💖💖🥺,,,👉👈💖💖✨,👉👈Returns
String
def verify_bottom(string : String)
Validates the given
Stringinstance. Raises anArgumentErrorif string is not a valid bottom-encoded string or the string is not valid a valid UTF8 string.Example:
Valid:
puts Bottom.verify_bottom("💖✨✨,,👉👈💖💖,👉👈💖💖🥺,,,👉👈💖💖🥺,,,👉👈💖💖✨,👉👈") # Output: nilInvalid:
puts Bottom.verify_bottom("Hello") # Output: ArgumentErrorReturns
nil
Contributors
- arHSM - creator and maintainer
bottom-cr
- 0
- 0
- 0
- 0
- 0
- almost 4 years ago
- April 13, 2022
MIT License
Tue, 27 Jan 2026 19:08:31 GMT