Created
October 26, 2021 06:04
-
-
Save jinwoo1225/6629f6f0c828d8523024e42b4b713b86 to your computer and use it in GitHub Desktop.
go lang length of string
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" | |
"strings" | |
) | |
func main() { | |
//https://golang.org/doc/effective_go#for | |
korean := "한국어" // korean 3words | |
english := "eng" // english 3words | |
outOfASCII := "àšź" // idk 3words | |
fmt.Printf("%T\n", korean) // string은 비정형?.... | |
fmt.Printf("%T\n", english) | |
fmt.Printf("%T\n", outOfASCII) | |
fmt.Println(strings.Repeat("-", 10)) | |
fmt.Println(len(korean)) | |
fmt.Println(len(english)) | |
fmt.Println(len(outOfASCII)) | |
fmt.Println(strings.Repeat("-", 10)) | |
fmt.Println(len([]rune(korean))) | |
fmt.Println(len([]rune(english))) | |
fmt.Println(len([]rune(outOfASCII))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment