Created
August 2, 2016 15:43
-
-
Save ladrift/5ff3a261c9926af6b19077cc0d2a35c5 to your computer and use it in GitHub Desktop.
String literals and rune literals in Go
This file contains 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() { | |
s1 := `日` | |
fmt.Printf("%q\n", s1) | |
fmt.Printf("% x\n", s1) // Using the "space" flag for format. | |
// Output: | |
// "日" | |
// e6 97 a5 | |
s2 := "\xe6\x97\xa5" | |
fmt.Printf("%q\n", s2) | |
// Output: | |
// "日" | |
// r := '\xe6\x97\xa5' // Illegal rune literal | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment