Skip to content

Instantly share code, notes, and snippets.

@manjeettahkur
Created January 29, 2022 08:25
Show Gist options
  • Save manjeettahkur/d4b4e30b6a75eebf1e9b8bba83926d19 to your computer and use it in GitHub Desktop.
Save manjeettahkur/d4b4e30b6a75eebf1e9b8bba83926d19 to your computer and use it in GitHub Desktop.
verbs for print character in golang
package main
import "fmt"
func main() {
s := "Hello world!"
fmt.Printf("%c\n", s[0]) // the character represented by the corresponding Unicode code point
fmt.Printf("%q\n", s[0]) // a single-quoted character (rune) at index 0
fmt.Printf("%U\n", s[0]) // print Unicode code point at index 0
fmt.Printf("%b\n", s[0]) // print binary representation of Unicode code point at index 0
fmt.Printf("%o\n", s[0]) // print octal representation of Unicode code point at index 0
fmt.Printf("%d\n", s[0]) // print decimal representation of Unicode code point at index 0
fmt.Printf("%x\n", s[0]) // print hexadecimal representation of Unicode code point at index 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment