Golang : Experimental emojis or emoticons icons programming language
So, after I published my experimental Jawi programming language code on Facebook, someone asked me if it is possible to code in any other human languages such as Kristang or emojis/emotion icons? The answer is YES. Below is an adaptation of the previous code but with a slightly different dictionary.
In the dictionary, the Golang's reserved words are mapped to some randomly selected emojis for this demo. You can replace the [bikini-icon], [shit-icon], etc with proper emojis before running this code below or copy the code at https://play.golang.org/p/GLlL8v_XdQa
Here you go!
package main
import (
"fmt"
"strings"
"text/scanner"
)
func main() {
emojisGolang := map[string]string{}
dictionary := `var,[bikini-icon]
Println,[ghost-icon]
const,[devil-icon]
package,[briefcase-icon]
import,[smiley-icon]
main,[shit-icon]
func,[candy-icon]`
lines := strings.Split(dictionary, "\n")
// build the dictionary
for _, line := range lines {
if len(line) > 0 {
split := strings.Split(line, ",")
golang := split[0]
emojis := split[1]
emojisGolang[emojis] = golang
}
}
//test
emojisCode := `
[briefcase-icon] [shit-icon]
[smiley-icon] (
"fmt"
)
[bikini-icon] txt = "هاي دنيا ! 世界汝好 ! Hello World ! "
[candy-icon] [shit-icon]() {
fmt.[ghost-icon](txt)
}`
codeReader := strings.NewReader(emojisCode)
var scn scanner.Scanner
scn.Init(codeReader)
scn.Whitespace ^= 1<<'\t' | 1<<'\n' | 1<<'\r' | 1<<' ' // don't skip tabs and new lines
for tok := scn.Scan(); tok != scanner.EOF; tok = scn.Scan() {
switch tok {
case '\n':
fmt.Println()
case '\t':
fmt.Print(" ")
default:
if emojisGolang[scn.TokenText()] != "" {
fmt.Print(emojisGolang[scn.TokenText()])
} else {
fmt.Print(scn.TokenText())
}
}
}
fmt.Println()
}
You can run the code at : https://play.golang.org/p/GLlL8v_XdQa
Reference :
https://socketloop.com/tutorials/golang-experimental-jawi-programming-language
See also : Golang : Experimental Jawi programming language
By Adam Ng(黃武俊)
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+41.3k Golang : Convert string to array/slice
+8.7k Golang : Random integer with rand.Seed() within a given range
+8.3k Golang : Generate Datamatrix barcode
+29.3k Golang : How to create new XML file ?
+5.9k PHP : Get client IP address
+4.9k Golang : micron to centimeter example
+5.5k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+4.3k Golang : Valued expressions and functions example
+19k Mac OSX : Homebrew and Golang
+13.5k Golang : Set image canvas or background to transparent
+20.2k nginx: [emerg] unknown directive "passenger_enabled"
+18.6k Golang : convert int to string