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?