Hello gophers.

Written by
Link to Post

https://www.reddit.com/r/golang/comments/b0qob0/hello_gophers/ by 

How are we supposed to deal with strings that have characters that can only be represented by multiple Unicode code points. ? Which means those characters cannot be represented in a single rune.

As an example var x rune = ‘ன்’

That line will print a compilation error because that character cannot be represented in a single rune even though in that language that glyph is a valid character.

Seems like the only way to save that character is to use a rune or byte slice. Say I have,

x := []rune(“ன்”)

That compiles. But now I can’t do a proper count. len(x) will be give me 2 and not 1.

There are many other string manipulation operations I cannot properly do if strings have characters occupying multiple runes.

What am I missing?. I’m new to go. I find it hard to believe that string manipulation in go can only be achieved if you’re willing to climb through hoops.

submitted by /u/desijays
[link] [comments]

Article Tags:
· ·
Article Categories:

Leave a Reply