On Mon, Jun 14, 2021 at 3:23 PM Roland Müller <rol...@gmail.com> wrote: > > Hello, > > Am Mo., 14. Juni 2021 um 03:24 Uhr schrieb Amit Saha <amitsaha...@gmail.com>: >> >> Hi - My main motivation to understand this is i always had to google >> this - how to convert a string to a byte slice. >> >> Is []byte a type that has been defined in the compiler? >> >> Or, is that an internal level detail that an earlier stage (parsing) >> takes care of when the compiler sees that statement? >> >> Thanks, >> Amit >> > > a []byte is a sequence of octets and strings in Go consistent of a bytes. > These bytes represent an sequence of unicode characters according to UTF-8. > One such character consists of either a single or two bytes. ASCII -only > strings than have as many bytes as UTF characters. > > In the example I made two loop functions loopStringByBytes(s) and > loopStringByChars(s) and checked them against a ASCII string and a cyrillic > string. You can see that for second string every character occupies 2 bytes. > > https://play.golang.org/p/DDSpiFuR8Lp
Thank you. > > BR, > Roland > > >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/golang-nuts/CANODV3nBYmshDLFwUUdnnyVuvpjhWnwBJOb%3DwrZKEHXmtBgbSg%40mail.gmail.com. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CANODV3k6XpFuP943bC7CCT9nnnFz5J_-trL%3D7rAgowsgWZj%3Drg%40mail.gmail.com.