Skip to content

Instantly share code, notes, and snippets.

@nexus166
Forked from YamiOdymel/emoji.go
Last active November 5, 2019 02:27
Show Gist options
  • Save nexus166/8197feef990ac4eb6f7b0366b28ee5a9 to your computer and use it in GitHub Desktop.
Save nexus166/8197feef990ac4eb6f7b0366b28ee5a9 to your computer and use it in GitHub Desktop.
golang codepage emojis
package main
import (
"fmt"
"html"
)
func main() {
// Hexadecimal ranges from: http://unicode.myseosolution.de/
emoji := [][]int{
// Playing cards :D
{128768, 128895},
// Misc
{127744, 128511},
// Emoticons icons
{128513, 128591},
// Dingbats
{9986, 10160},
// Transport and map symbols.
{128640, 128767},
// Alchemical
//{128768, 128895},
}
for _, value := range emoji {
for x := value[0]; x < value[1]; x++ {
i := intStr(x)
// Unescape the string (HTML Entity -> String).
if str := codepageToEmoji(i); str != "" {
// Display the emoji.
fmt.Println(i + ":\t" + str)
}
}
}
}
func intStr(i int) string {
return fmt.Sprintf("%d", i)
}
func codepageToEmoji(s string) string {
return html.UnescapeString("&#" + s + ";")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment