package multibase import ( "strconv" "strings" "unicode/utf8" ) var base256emojiTable = [256]rune{ // Curated list, this is just a list of things that *somwhat* are related to our comunity '๐Ÿš€', '๐Ÿช', 'โ˜„', '๐Ÿ›ฐ', '๐ŸŒŒ', // Space '๐ŸŒ‘', '๐ŸŒ’', '๐ŸŒ“', '๐ŸŒ”', '๐ŸŒ•', '๐ŸŒ–', '๐ŸŒ—', '๐ŸŒ˜', // Moon '๐ŸŒ', '๐ŸŒ', '๐ŸŒŽ', // Our Home, for now (earth) '๐Ÿ‰', // Dragon!!! 'โ˜€', // Our Garden, for now (sol) '๐Ÿ’ป', '๐Ÿ–ฅ', '๐Ÿ’พ', '๐Ÿ’ฟ', // Computer // The rest is completed from https://home.unicode.org/emoji/emoji-frequency/ at the time of creation (december 2021) (the data is from 2019), most used first until we reach 256. // We exclude modifier based emojies (such as flags) as they are bigger than one single codepoint. // Some other emojies were removed adhoc for various reasons. '๐Ÿ˜‚', 'โค', '๐Ÿ˜', '๐Ÿคฃ', '๐Ÿ˜Š', '๐Ÿ™', '๐Ÿ’•', '๐Ÿ˜ญ', '๐Ÿ˜˜', '๐Ÿ‘', '๐Ÿ˜…', '๐Ÿ‘', '๐Ÿ˜', '๐Ÿ”ฅ', '๐Ÿฅฐ', '๐Ÿ’”', '๐Ÿ’–', '๐Ÿ’™', '๐Ÿ˜ข', '๐Ÿค”', '๐Ÿ˜†', '๐Ÿ™„', '๐Ÿ’ช', '๐Ÿ˜‰', 'โ˜บ', '๐Ÿ‘Œ', '๐Ÿค—', '๐Ÿ’œ', '๐Ÿ˜”', '๐Ÿ˜Ž', '๐Ÿ˜‡', '๐ŸŒน', '๐Ÿคฆ', '๐ŸŽ‰', '๐Ÿ’ž', 'โœŒ', 'โœจ', '๐Ÿคท', '๐Ÿ˜ฑ', '๐Ÿ˜Œ', '๐ŸŒธ', '๐Ÿ™Œ', '๐Ÿ˜‹', '๐Ÿ’—', '๐Ÿ’š', '๐Ÿ˜', '๐Ÿ’›', '๐Ÿ™‚', '๐Ÿ’“', '๐Ÿคฉ', '๐Ÿ˜„', '๐Ÿ˜€', '๐Ÿ–ค', '๐Ÿ˜ƒ', '๐Ÿ’ฏ', '๐Ÿ™ˆ', '๐Ÿ‘‡', '๐ŸŽถ', '๐Ÿ˜’', '๐Ÿคญ', 'โฃ', '๐Ÿ˜œ', '๐Ÿ’‹', '๐Ÿ‘€', '๐Ÿ˜ช', '๐Ÿ˜‘', '๐Ÿ’ฅ', '๐Ÿ™‹', '๐Ÿ˜ž', '๐Ÿ˜ฉ', '๐Ÿ˜ก', '๐Ÿคช', '๐Ÿ‘Š', '๐Ÿฅณ', '๐Ÿ˜ฅ', '๐Ÿคค', '๐Ÿ‘‰', '๐Ÿ’ƒ', '๐Ÿ˜ณ', 'โœ‹', '๐Ÿ˜š', '๐Ÿ˜', '๐Ÿ˜ด', '๐ŸŒŸ', '๐Ÿ˜ฌ', '๐Ÿ™ƒ', '๐Ÿ€', '๐ŸŒท', '๐Ÿ˜ป', '๐Ÿ˜“', 'โญ', 'โœ…', '๐Ÿฅบ', '๐ŸŒˆ', '๐Ÿ˜ˆ', '๐Ÿค˜', '๐Ÿ’ฆ', 'โœ”', '๐Ÿ˜ฃ', '๐Ÿƒ', '๐Ÿ’', 'โ˜น', '๐ŸŽŠ', '๐Ÿ’˜', '๐Ÿ˜ ', 'โ˜', '๐Ÿ˜•', '๐ŸŒบ', '๐ŸŽ‚', '๐ŸŒป', '๐Ÿ˜', '๐Ÿ–•', '๐Ÿ’', '๐Ÿ™Š', '๐Ÿ˜น', '๐Ÿ—ฃ', '๐Ÿ’ซ', '๐Ÿ’€', '๐Ÿ‘‘', '๐ŸŽต', '๐Ÿคž', '๐Ÿ˜›', '๐Ÿ”ด', '๐Ÿ˜ค', '๐ŸŒผ', '๐Ÿ˜ซ', 'โšฝ', '๐Ÿค™', 'โ˜•', '๐Ÿ†', '๐Ÿคซ', '๐Ÿ‘ˆ', '๐Ÿ˜ฎ', '๐Ÿ™†', '๐Ÿป', '๐Ÿƒ', '๐Ÿถ', '๐Ÿ’', '๐Ÿ˜ฒ', '๐ŸŒฟ', '๐Ÿงก', '๐ŸŽ', 'โšก', '๐ŸŒž', '๐ŸŽˆ', 'โŒ', 'โœŠ', '๐Ÿ‘‹', '๐Ÿ˜ฐ', '๐Ÿคจ', '๐Ÿ˜ถ', '๐Ÿค', '๐Ÿšถ', '๐Ÿ’ฐ', '๐Ÿ“', '๐Ÿ’ข', '๐ŸคŸ', '๐Ÿ™', '๐Ÿšจ', '๐Ÿ’จ', '๐Ÿคฌ', 'โœˆ', '๐ŸŽ€', '๐Ÿบ', '๐Ÿค“', '๐Ÿ˜™', '๐Ÿ’Ÿ', '๐ŸŒฑ', '๐Ÿ˜–', '๐Ÿ‘ถ', '๐Ÿฅด', 'โ–ถ', 'โžก', 'โ“', '๐Ÿ’Ž', '๐Ÿ’ธ', 'โฌ‡', '๐Ÿ˜จ', '๐ŸŒš', '๐Ÿฆ‹', '๐Ÿ˜ท', '๐Ÿ•บ', 'โš ', '๐Ÿ™…', '๐Ÿ˜Ÿ', '๐Ÿ˜ต', '๐Ÿ‘Ž', '๐Ÿคฒ', '๐Ÿค ', '๐Ÿคง', '๐Ÿ“Œ', '๐Ÿ”ต', '๐Ÿ’…', '๐Ÿง', '๐Ÿพ', '๐Ÿ’', '๐Ÿ˜—', '๐Ÿค‘', '๐ŸŒŠ', '๐Ÿคฏ', '๐Ÿท', 'โ˜Ž', '๐Ÿ’ง', '๐Ÿ˜ฏ', '๐Ÿ’†', '๐Ÿ‘†', '๐ŸŽค', '๐Ÿ™‡', '๐Ÿ‘', 'โ„', '๐ŸŒด', '๐Ÿ’ฃ', '๐Ÿธ', '๐Ÿ’Œ', '๐Ÿ“', '๐Ÿฅ€', '๐Ÿคข', '๐Ÿ‘…', '๐Ÿ’ก', '๐Ÿ’ฉ', '๐Ÿ‘', '๐Ÿ“ธ', '๐Ÿ‘ป', '๐Ÿค', '๐Ÿคฎ', '๐ŸŽผ', '๐Ÿฅต', '๐Ÿšฉ', '๐ŸŽ', '๐ŸŠ', '๐Ÿ‘ผ', '๐Ÿ’', '๐Ÿ“ฃ', '๐Ÿฅ‚', } var base256emojiReverseTable map[rune]byte func init() { base256emojiReverseTable = make(map[rune]byte, len(base256emojiTable)) for i, v := range base256emojiTable { base256emojiReverseTable[v] = byte(i) } } func base256emojiEncode(in []byte) string { var l int for _, v := range in { l += utf8.RuneLen(base256emojiTable[v]) } var out strings.Builder out.Grow(l) for _, v := range in { out.WriteRune(base256emojiTable[v]) } return out.String() } type base256emojiCorruptInputError struct { index int char rune } func (e base256emojiCorruptInputError) Error() string { return "illegal base256emoji data at input byte " + strconv.FormatInt(int64(e.index), 10) + ", char: '" + string(e.char) + "'" } func (e base256emojiCorruptInputError) String() string { return e.Error() } func base256emojiDecode(in string) ([]byte, error) { out := make([]byte, utf8.RuneCountInString(in)) var stri int for i := 0; len(in) > 0; i++ { r, n := utf8.DecodeRuneInString(in) in = in[n:] var ok bool out[i], ok = base256emojiReverseTable[r] if !ok { return nil, base256emojiCorruptInputError{stri, r} } stri += n } return out, nil }