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
+18.2k Golang : Logging with logrus
+10.9k CodeIgniter : How to check if a session exist in PHP?
+35.6k Golang : Get file last modified date and time
+18.6k Golang : Delete duplicate items from a slice/array
+9.1k Golang : How to protect your source code from client, hosting company or hacker?
+24.2k Golang : Time slice or date sort and reverse sort example
+5.6k Cash Flow : 50 days to pay your credit card debt
+7.2k Golang : Hue, Saturation and Value(HSV) with OpenCV example
+9.9k Golang : Compare files modify date example
+4.4k Mac OSX : Get disk partitions' size, type and name
+8k Golang : Reverse text lines or flip line order example
+26k Golang : Convert(cast) string to uint8 type and back to string