DEV Community

Nitin Bansal
Nitin Bansal

Posted on

So you know strings in golang, hun?πŸ˜’

Task: Iterate over a string and print each character.... Without using external libraries.

func main() {
    var s string = "hπŸ‘πŸ»e"
    for i, c := range []rune(s) {
        fmt.Println(i, string(c))
    }
}
Enter fullscreen mode Exit fullscreen mode

This prints:

0 h
1 πŸ‘
2 🏻
3 e
Enter fullscreen mode Exit fullscreen mode

What it should print instead:

0 h
1 πŸ‘πŸ»
2 e
Enter fullscreen mode Exit fullscreen mode

So, can you make this work?

Hint: The emoji used in string is skin-toned, not default.

Top comments (2)

Collapse
 
lil5 profile image
Lucian I. Last

This has nothing to do with GoLang, rather is has to do with ascii emoji encoding and fonts

Collapse
 
freakynit profile image
Nitin Bansal

But, can you make it work?