Skip to content

Instantly share code, notes, and snippets.

@ladrift
Created August 2, 2016 15:43
Show Gist options
  • Save ladrift/5ff3a261c9926af6b19077cc0d2a35c5 to your computer and use it in GitHub Desktop.
Save ladrift/5ff3a261c9926af6b19077cc0d2a35c5 to your computer and use it in GitHub Desktop.
String literals and rune literals in Go
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