Created
January 29, 2022 08:25
-
-
Save manjeettahkur/d4b4e30b6a75eebf1e9b8bba83926d19 to your computer and use it in GitHub Desktop.
verbs for print character in golang
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 := "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