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
+19.9k Golang : Count number of digits from given integer value
+19.8k Golang : How to get own program name during runtime ?
+24.2k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?
+17.3k Golang : Find smallest number in array
+12.4k Golang : Remove or trim extra comma from CSV
+13.9k Golang : Check if a file exist or not
+6.2k PHP : Proper way to get UTF-8 character or string length
+10.3k RPM : error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
+5.4k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+35.6k Golang : Get file last modified date and time
+16.5k Golang : Get the IPv4 and IPv6 addresses for a specific network interface
+13.5k Golang : How to determine if a year is leap year?