Swiftpack.co -  robindiddams/ecoji-swift as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
robindiddams/ecoji-swift
Encode and decode data as emojis, in Swift 5
.package(url: "https://github.com/robindiddams/ecoji-swift.git", from: "1.1.1")

Ecoji-Swift

CocoaPods Compatible Swift Package Manager compatible

A Swift 5 implementation of the Ecoji encoding standard.

Provides a library for encoding and decoding data as a base-1024 sequence of emojis

Visit ecoji.io to try Ecoji in your browser.

Install

  pod 'Ecoji'

Usage

Works a lot like a JSONEncoder/Decoder

Encoding

Encode is implemented for Data or String inputs

import Ecoji
let encoder = EcojiEncoder()
let emojiString = encoder.encode(from: "Hello World!")
print(emojiString)
// "πŸ―πŸ”©πŸš—πŸŒ·πŸ‰πŸ‘‡πŸ¦’πŸ•ŠπŸ‘‘πŸ“’β˜•β˜•"

Decoding

You can decode into Data like this:

let decoder = EcojiDecoder()
do {
  let data = try decoder.decode(string: "πŸ―πŸ”©πŸš—πŸŒ·πŸ‰πŸ‘‡πŸ¦’πŸ•ŠπŸ‘‘πŸ“’β˜•β˜•"
  print(data)
  // "12 bytes"
} catch let err as DecodingError {
  print(err)
}

Theres also a convenience method for reconstruction utf strings from the data:

let decoder = EcojiDecoder()
do {
  let data = try decoder.decodeToString(string: "πŸ―πŸ”©πŸš—πŸŒ·πŸ‰πŸ‘‡πŸ¦’πŸ•ŠπŸ‘‘πŸ“’β˜•β˜•"
  print(data)
  // "Hello World!"
} catch let err as DecodingError {
  print(err)
}

TODO:

  • β˜‘ Decode/Encode
  • β˜‘ Tests
  • ☐ Linux compatibility
  • β˜‘ swift package manager
  • β˜‘ cocoa pod

Contribution

PRs welcome!

check test cases with swift test

License

Like the rust implementation this program is licensed under either of

at your option.

GitHub

link
Stars: 6
Last commit: 12 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API