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
+76.9k Golang : How to return HTTP status code?
+28.8k Golang : How to create new XML file ?
+21.6k Golang : Match strings by wildcard patterns with filepath.Match() function
+7.9k Golang : Oanda bot with Telegram and RSI example
+17.1k Golang : delete and modify XML file content
+10.1k Golang : How to unmarshal JSON inner/nested value and assign to specific struct?
+26.6k Golang : Find files by name - cross platform example
+6.9k Golang : How to detect if a sentence ends with a punctuation?
+8k Golang : Ackermann function example
+8.7k Golang : Apply Histogram Equalization to color images
+11.8k Golang : md5 hash of a string
+9k Golang : Scramble and unscramble text message by randomly replacing words