Last active
May 31, 2016 04:17
-
-
Save pinzolo/f112754435656b42445002c8d14e8487 to your computer and use it in GitHub Desktop.
Get rune from string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
s := "日本語" | |
fmt.Println(string(s[0])) // => æ | |
fmt.Println(string(getRuneAt(s, 0))) // => 日 | |
} | |
func getRuneAt(s string, i int) rune { | |
rs := []rune(s) | |
return rs[i] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment