package main
import ("fmt")
func main() {
lenString: = len("САЛИХА ХАМЗЕЕВНА ГАРИПОВА САЛ ХА ХАМЗЕ ВНА ГАР ПОВА") fmt.Println(lenString)
}
Why the length of the string is returning 94 although the length is 51 of the mentioned string
package main
import ("fmt")
func main() {
lenString: = len("САЛИХА ХАМЗЕЕВНА ГАРИПОВА САЛ ХА ХАМЗЕ ВНА ГАР ПОВА") fmt.Println(lenString)
}
Why the length of the string is returning 94 although the length is 51 of the mentioned string
As per documentation len
method is counting number of bytes in string. Characters in your string are mostly utf-8 encoded. So one character up to 4 bytes: https://en.wikipedia.org/wiki/UTF-8. So one character is taking more then one byte in your string.
Here is online tool that can prove your results: https://mothereff.in/byte-counter