1
0
Fork 0
mirror of https://github.com/emojisum/emojisum.git synced 2025-02-13 04:37:50 +00:00

Merge pull request #2 from vbatts/draft

emoji: make the list an independent doc
This commit is contained in:
Vincent Batts 2016-12-13 14:20:50 -05:00 committed by GitHub
commit e18869e595
8 changed files with 684 additions and 266 deletions

View file

@ -7,6 +7,10 @@ I attempted a curated list of 256 emojis that are not entirely similar. Using ht
So 1 emoji is 2 hex positions. So 1 emoji is 2 hex positions.
## draft practice
For information on the draft for broader practice, see [the draft](./emoji/README.md).
## build ## build
```bash ```bash

64
emoji/README.md Normal file
View file

@ -0,0 +1,64 @@
Emoji Working Group
Category: Informational
# emoji checksum mapping
## Status of This Document
This document provides information for the community. This document does not
specify a standard of any kind. It is open to suggestions and discussion for
improvements. This document is presently a draft and will apply versioning of
the documents as needed. Distribution of this document is unlimited.
## Notices
Permission is granted to copy and distribute this document for any purpose and
without charge, including translations into other languages and incorporation
into compilations, provided that the copyright notice and this notice are
preserved, and that any substantive changes or deletions from the original are
clearly marked.
A pointer to the latest version of this and related documentation in HTML
format can be found at the URL
[http://emoji.thisco.de/draft/emojimap.json](http://emoji.thisco.de/draft/emojimap.json)
## Abstract
This document specifies a practice of mapping an 8bit byte to one of a
corresponding list of 256 emoji strings.
The [`emojimap.json`](./emojimap.json) JSON is the authority of ordering.
While this directory contains golang source that is is importable by golang
projects, other languages can fetch the ordered list of the JSON document and
do their own emojisum comparison or rendering.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
interpreted as described in [RFC 2119](https://tools.ietf.org/html/rfc2119).
## Introduction
### Purpose
The purpose of this practice is provide simplified way to convey [checksums](https://en.wikipedia.org/wiki/Checksum) for visual comparison.
### Intended Audience
This is intended for use by implementors of software to convey checksums or validate conveyed checksums.
## Details
By operating on an 8bit byte, this provides the oportunity for 256 permutations.
Most checksums convey in a hexadecimal notation, there showing a par of case-insensitive hexadecimal characters per byte (`16*16 = 256`).
Having a mapping of 256 emojis this thereby reduces the number of characters (or emojis) needed to convey the checksum.
In example, a [SHA1](https://en.wikipedia.org/wiki/SHA-1) checksum is 40 hexadecimal characters long, whereas an SHA1-emojisum is only 20 emojis.
## References
* http://www.webpagefx.com/tools/emoji-cheat-sheet/

262
emoji/emojimap.json Normal file
View file

@ -0,0 +1,262 @@
{
"version": "draft",
"description": "This ordered list of emojiwords is the conventional order for the practice of conveying checksums with emoji",
"emojiwords": [
":+1:",
":8ball:",
":airplane:",
":alien:",
":anchor:",
":angel:",
":angry:",
":ant:",
":apple:",
":art:",
":baby:",
":baby_bottle:",
":back:",
":bamboo:",
":banana:",
":barber:",
":bathtub:",
":beer:",
":bell:",
":bicyclist:",
":bird:",
":birthday:",
":blossom:",
":blue_car:",
":boar:",
":bomb:",
":boom:",
":bow:",
":boy:",
":broken_heart:",
":bulb:",
":bus:",
":cactus:",
":calendar:",
":camera:",
":candy:",
":cat:",
":cherries:",
":children_crossing:",
":chocolate_bar:",
":clap:",
":cloud:",
":clubs:",
":cn:",
":coffee:",
":construction:",
":cookie:",
":copyright:",
":corn:",
":cow:",
":crescent_moon:",
":crown:",
":cry:",
":crystal_ball:",
":curly_loop:",
":dancers:",
":dash:",
":de:",
":diamonds:",
":dog:",
":doughnut:",
":dragon:",
":dvd:",
":ear:",
":eggplant:",
":elephant:",
":end:",
":envelope:",
":es:",
":eyes:",
":facepunch:",
":family:",
":ferris_wheel:",
":finnadie:",
":fire:",
":fireworks:",
":floppy_disk:",
":football:",
":fork_and_knife:",
":four_leaf_clover:",
":fr:",
":fries:",
":frog:",
":fu:",
":full_moon:",
":game_die:",
":eu:",
":gem:",
":girl:",
":goat:",
":grimacing:",
":grin:",
":guardsman:",
":guitar:",
":gun:",
":hamburger:",
":hammer:",
":hamster:",
":hear_no_evil:",
":heart:",
":heart_eyes_cat:",
":hearts:",
":heavy_check_mark:",
":moyai:",
":izakaya_lantern:",
":helicopter:",
":hocho:",
":honeybee:",
":horse:",
":horse_racing:",
":hourglass:",
":house:",
":hurtrealbad:",
":icecream:",
":imp:",
":it:",
":jack_o_lantern:",
":japanese_goblin:",
":jp:",
":key:",
":kiss:",
":kissing_cat:",
":koala:",
":kr:",
":lemon:",
":lipstick:",
":lock:",
":lollipop:",
":man:",
":maple_leaf:",
":mask:",
":metal:",
":microscope:",
":moneybag:",
":monkey:",
":mount_fuji:",
":muscle:",
":mushroom:",
":musical_keyboard:",
":musical_score:",
":nail_care:",
":new_moon:",
":no_entry:",
":nose:",
":notes:",
":nut_and_bolt:",
":o:",
":ocean:",
":ok_hand:",
":on:",
":package:",
":palm_tree:",
":panda_face:",
":paperclip:",
":partly_sunny:",
":passport_control:",
":paw_prints:",
":peach:",
":penguin:",
":phone:",
":pig:",
":pill:",
":pineapple:",
":pizza:",
":point_left:",
":point_right:",
":poop:",
":poultry_leg:",
":pray:",
":princess:",
":purse:",
":pushpin:",
":rabbit:",
":rainbow:",
":raised_hand:",
":recycle:",
":red_car:",
":registered:",
":ribbon:",
":rice:",
":rocket:",
":roller_coaster:",
":rooster:",
":ru:",
":sailboat:",
":santa:",
":satellite:",
":satisfied:",
":saxophone:",
":scissors:",
":see_no_evil:",
":sheep:",
":shell:",
":shoe:",
":ski:",
":skull:",
":sleepy:",
":smile:",
":smiley_cat:",
":smirk:",
":smoking:",
":snail:",
":snake:",
":snowflake:",
":soccer:",
":soon:",
":space_invader:",
":spades:",
":speak_no_evil:",
":star:",
":stars:",
":statue_of_liberty:",
":steam_locomotive:",
":sunflower:",
":sunglasses:",
":sunny:",
":sunrise:",
":surfer:",
":swimmer:",
":syringe:",
":tada:",
":tangerine:",
":taxi:",
":tennis:",
":tent:",
":thought_balloon:",
":tm:",
":toilet:",
":tongue:",
":tophat:",
":tractor:",
":trolleybus:",
":trollface:",
":trophy:",
":trumpet:",
":turtle:",
":two_men_holding_hands:",
":two_women_holding_hands:",
":uk:",
":umbrella:",
":unlock:",
":us:",
":v:",
":vhs:",
":violin:",
":warning:",
":watermelon:",
":wave:",
":wavy_dash:",
":wc:",
":wheelchair:",
":woman:",
":x:",
":yum:",
":zap:",
":zzz:"
]
}

25
emoji/map.go Normal file
View file

@ -0,0 +1,25 @@
//go:generate go run map_json.go -in ./emojimap.json -out ./map_gen.go
package emoji
// Map returns the emoji at the provided position.
// This list is from 0-255
func Map(b byte) string {
return mapGen.EmojiWords[int(b)]
}
// Version returns the version of the emojisum document currently compiled
// against
func Version() string {
return mapGen.Version
}
var mapGen VersionedMap
// VersionedMap is the structure used for the `emojimap.json` document
type VersionedMap struct {
Description string `json:"description"`
Version string `json:"version"`
// these are an ordered list, referened by a byte (each byte of a checksum digest)
EmojiWords []string `json:"emojiwords"`
}

268
emoji/map_gen.go Normal file
View file

@ -0,0 +1,268 @@
// THIS FILE IS GENERATED. DO NOT EDIT.
package emoji
func init() {
mapGen = VersionedMap{
Description: "",
Version: "draft",
EmojiWords: []string{
":+1:",
":8ball:",
":airplane:",
":alien:",
":anchor:",
":angel:",
":angry:",
":ant:",
":apple:",
":art:",
":baby:",
":baby_bottle:",
":back:",
":bamboo:",
":banana:",
":barber:",
":bathtub:",
":beer:",
":bell:",
":bicyclist:",
":bird:",
":birthday:",
":blossom:",
":blue_car:",
":boar:",
":bomb:",
":boom:",
":bow:",
":boy:",
":broken_heart:",
":bulb:",
":bus:",
":cactus:",
":calendar:",
":camera:",
":candy:",
":cat:",
":cherries:",
":children_crossing:",
":chocolate_bar:",
":clap:",
":cloud:",
":clubs:",
":cn:",
":coffee:",
":construction:",
":cookie:",
":copyright:",
":corn:",
":cow:",
":crescent_moon:",
":crown:",
":cry:",
":crystal_ball:",
":curly_loop:",
":dancers:",
":dash:",
":de:",
":diamonds:",
":dog:",
":doughnut:",
":dragon:",
":dvd:",
":ear:",
":eggplant:",
":elephant:",
":end:",
":envelope:",
":es:",
":eyes:",
":facepunch:",
":family:",
":ferris_wheel:",
":finnadie:",
":fire:",
":fireworks:",
":floppy_disk:",
":football:",
":fork_and_knife:",
":four_leaf_clover:",
":fr:",
":fries:",
":frog:",
":fu:",
":full_moon:",
":game_die:",
":eu:",
":gem:",
":girl:",
":goat:",
":grimacing:",
":grin:",
":guardsman:",
":guitar:",
":gun:",
":hamburger:",
":hammer:",
":hamster:",
":hear_no_evil:",
":heart:",
":heart_eyes_cat:",
":hearts:",
":heavy_check_mark:",
":moyai:",
":izakaya_lantern:",
":helicopter:",
":hocho:",
":honeybee:",
":horse:",
":horse_racing:",
":hourglass:",
":house:",
":hurtrealbad:",
":icecream:",
":imp:",
":it:",
":jack_o_lantern:",
":japanese_goblin:",
":jp:",
":key:",
":kiss:",
":kissing_cat:",
":koala:",
":kr:",
":lemon:",
":lipstick:",
":lock:",
":lollipop:",
":man:",
":maple_leaf:",
":mask:",
":metal:",
":microscope:",
":moneybag:",
":monkey:",
":mount_fuji:",
":muscle:",
":mushroom:",
":musical_keyboard:",
":musical_score:",
":nail_care:",
":new_moon:",
":no_entry:",
":nose:",
":notes:",
":nut_and_bolt:",
":o:",
":ocean:",
":ok_hand:",
":on:",
":package:",
":palm_tree:",
":panda_face:",
":paperclip:",
":partly_sunny:",
":passport_control:",
":paw_prints:",
":peach:",
":penguin:",
":phone:",
":pig:",
":pill:",
":pineapple:",
":pizza:",
":point_left:",
":point_right:",
":poop:",
":poultry_leg:",
":pray:",
":princess:",
":purse:",
":pushpin:",
":rabbit:",
":rainbow:",
":raised_hand:",
":recycle:",
":red_car:",
":registered:",
":ribbon:",
":rice:",
":rocket:",
":roller_coaster:",
":rooster:",
":ru:",
":sailboat:",
":santa:",
":satellite:",
":satisfied:",
":saxophone:",
":scissors:",
":see_no_evil:",
":sheep:",
":shell:",
":shoe:",
":ski:",
":skull:",
":sleepy:",
":smile:",
":smiley_cat:",
":smirk:",
":smoking:",
":snail:",
":snake:",
":snowflake:",
":soccer:",
":soon:",
":space_invader:",
":spades:",
":speak_no_evil:",
":star:",
":stars:",
":statue_of_liberty:",
":steam_locomotive:",
":sunflower:",
":sunglasses:",
":sunny:",
":sunrise:",
":surfer:",
":swimmer:",
":syringe:",
":tada:",
":tangerine:",
":taxi:",
":tennis:",
":tent:",
":thought_balloon:",
":tm:",
":toilet:",
":tongue:",
":tophat:",
":tractor:",
":trolleybus:",
":trollface:",
":trophy:",
":trumpet:",
":turtle:",
":two_men_holding_hands:",
":two_women_holding_hands:",
":uk:",
":umbrella:",
":unlock:",
":us:",
":v:",
":vhs:",
":violin:",
":warning:",
":watermelon:",
":wave:",
":wavy_dash:",
":wc:",
":wheelchair:",
":woman:",
":x:",
":yum:",
":zap:",
":zzz:",
},
}
}

13
emoji/map_gen.tmpl Normal file
View file

@ -0,0 +1,13 @@
// THIS FILE IS GENERATED. DO NOT EDIT.
package emoji
func init() {
mapGen = VersionedMap{
Description: "{{.Description}}",
Version: "{{.Version}}",
EmojiWords: []string{ {{- range .EmojiWords }}
"{{.}}",{{- end }}
},
}
}

46
emoji/map_json.go Normal file
View file

@ -0,0 +1,46 @@
// +build ignore
package main
import (
"encoding/json"
"flag"
"log"
"os"
"text/template"
"github.com/vbatts/emojisum/emoji"
)
func main() {
flag.Parse()
input, err := os.Open(*flInput)
if err != nil {
log.Fatal(err)
}
defer input.Close()
vm := emoji.VersionedMap{}
dec := json.NewDecoder(input)
if err := dec.Decode(&vm); err != nil {
log.Fatal(err)
}
output, err := os.Create(*flOutput)
if err != nil {
log.Fatal(err)
}
defer output.Close()
mapGoTemp := template.Must(template.ParseFiles(*flTemplate))
if err := mapGoTemp.Execute(output, vm); err != nil {
log.Fatal(err)
}
}
var (
flInput = flag.String("in", "emojimap.json", "json input")
flOutput = flag.String("out", "map_gen.go", "golang output")
flTemplate = flag.String("template", "map_gen.tmpl", "template of golang source to use")
)

268
main.go
View file

@ -12,6 +12,7 @@ import (
"strings" "strings"
"github.com/kyokomi/emoji" "github.com/kyokomi/emoji"
esum "github.com/vbatts/emojisum/emoji"
) )
func main() { func main() {
@ -173,272 +174,7 @@ func Sum(r io.Reader) ([]byte, error) {
func emojiFromBytes(buf []byte) string { func emojiFromBytes(buf []byte) string {
var ret string var ret string
for _, b := range buf { for _, b := range buf {
ret = ret + emojiFromRune(b) ret = ret + esum.Map(b)
} }
return ret return ret
} }
func emojiFromRune(b byte) string {
//fmt.Printf("%#v\n", b)
return emojiMap[int(b)]
}
// these are an ordered list, referened by a byte (each byte of a checksum digest)
var emojiMap = []string{
":+1:",
":8ball:",
":airplane:",
":alien:",
":anchor:",
":angel:",
":angry:",
":ant:",
":apple:",
":art:",
":baby:",
":baby_bottle:",
":back:",
":bamboo:",
":banana:",
":barber:",
":bathtub:",
":beer:",
":bell:",
":bicyclist:",
":bird:",
":birthday:",
":blossom:",
":blue_car:",
":boar:",
":bomb:",
":boom:",
":bow:",
":boy:",
":broken_heart:",
":bulb:",
":bus:",
":cactus:",
":calendar:",
":camera:",
":candy:",
":cat:",
":cherries:",
":children_crossing:",
":chocolate_bar:",
":clap:",
":cloud:",
":clubs:",
":cn:",
":coffee:",
":construction:",
":cookie:",
":copyright:",
":corn:",
":cow:",
":crescent_moon:",
":crown:",
":cry:",
":crystal_ball:",
":curly_loop:",
":dancers:",
":dash:",
":de:",
":diamonds:",
":dog:",
":doughnut:",
":dragon:",
":dvd:",
":ear:",
":eggplant:",
":elephant:",
":end:",
":envelope:",
":es:",
":eyes:",
":facepunch:",
":family:",
":ferris_wheel:",
":finnadie:",
":fire:",
":fireworks:",
":floppy_disk:",
":football:",
":fork_and_knife:",
":four_leaf_clover:",
":fr:",
":fries:",
":frog:",
":fu:",
":full_moon:",
":game_die:",
":eu:",
":gem:",
":girl:",
":goat:",
":grimacing:",
":grin:",
":guardsman:",
":guitar:",
":gun:",
":hamburger:",
":hammer:",
":hamster:",
":hear_no_evil:",
":heart:",
":heart_eyes_cat:",
":hearts:",
":heavy_check_mark:",
":moyai:",
":izakaya_lantern:",
":helicopter:",
":hocho:",
":honeybee:",
":horse:",
":horse_racing:",
":hourglass:",
":house:",
":hurtrealbad:",
":icecream:",
":imp:",
":it:",
":jack_o_lantern:",
":japanese_goblin:",
":jp:",
":key:",
":kiss:",
":kissing_cat:",
":koala:",
":kr:",
":lemon:",
":lipstick:",
":lock:",
":lollipop:",
":man:",
":maple_leaf:",
":mask:",
":metal:",
":microscope:",
":moneybag:",
":monkey:",
":mount_fuji:",
":muscle:",
":mushroom:",
":musical_keyboard:",
":musical_score:",
":nail_care:",
":new_moon:",
":no_entry:",
":nose:",
":notes:",
":nut_and_bolt:",
":o:",
":ocean:",
":ok_hand:",
":on:",
":package:",
":palm_tree:",
":panda_face:",
":paperclip:",
":partly_sunny:",
":passport_control:",
":paw_prints:",
":peach:",
":penguin:",
":phone:",
":pig:",
":pill:",
":pineapple:",
":pizza:",
":point_left:",
":point_right:",
":poop:",
":poultry_leg:",
":pray:",
":princess:",
":purse:",
":pushpin:",
":rabbit:",
":rainbow:",
":raised_hand:",
":recycle:",
":red_car:",
":registered:",
":ribbon:",
":rice:",
":rocket:",
":roller_coaster:",
":rooster:",
":ru:",
":sailboat:",
":santa:",
":satellite:",
":satisfied:",
":saxophone:",
":scissors:",
":see_no_evil:",
":sheep:",
":shell:",
":shoe:",
":ski:",
":skull:",
":sleepy:",
":smile:",
":smiley_cat:",
":smirk:",
":smoking:",
":snail:",
":snake:",
":snowflake:",
":soccer:",
":soon:",
":space_invader:",
":spades:",
":speak_no_evil:",
":star:",
":stars:",
":statue_of_liberty:",
":steam_locomotive:",
":sunflower:",
":sunglasses:",
":sunny:",
":sunrise:",
":surfer:",
":swimmer:",
":syringe:",
":tada:",
":tangerine:",
":taxi:",
":tennis:",
":tent:",
":thought_balloon:",
":tm:",
":toilet:",
":tongue:",
":tophat:",
":tractor:",
":trolleybus:",
":trollface:",
":trophy:",
":trumpet:",
":turtle:",
":two_men_holding_hands:",
":two_women_holding_hands:",
":uk:",
":umbrella:",
":unlock:",
":us:",
":v:",
":vhs:",
":violin:",
":warning:",
":watermelon:",
":wave:",
":wavy_dash:",
":wc:",
":wheelchair:",
":woman:",
":x:",
":yum:",
":zap:",
":zzz:",
}