I have a string in Chinese:
x = "你好"
I'd like to loop through it and do something with each character in it, something like:
for i, len := 0, len(x); i < len; i++ {
foo( x[i] ) // do sth.
}
I found that len(x)
would return 6
instead of 2
, after Google I found the method RuneCountInString
which would return the real length of the string, but I still don't know how to loop to make x[i]
get the right character, x[0] == '你'
for example..
Thanks