Character codes: Difference between revisions
Content added Content deleted
(added Go) |
m (→{{header|Go}}) |
||
Line 195: | Line 195: | ||
<lang go>fmt.Println('a') // prints "97" |
<lang go>fmt.Println('a') // prints "97" |
||
fmt.Println('π') // prints "960"</lang> |
fmt.Println('π') // prints "960"</lang> |
||
To obtain the character code of the first Unicode character in a UTF-8 string: |
|||
<lang go>rune, _ := utf8.DecodeRuneInString("π") |
|||
fmt.Println(rune) // prints "960"</lang> |
|||
To print the character represented by a character code, we can create a string of that character (by converting the character code to string, it encodes the character in UTF-8): |
To print the character represented by a character code, we can create a string of that character (by converting the character code to string, it encodes the character in UTF-8): |