News for hackers. Stuff that matters.
Re:Strings, bytes, runes and characters in Go by skybrian on Wednesday October 23, 2013 @09:04PM (#6602824)
Well, the first question is what a string's internal representation should be, and they went with UTF8. Once you've decided on UTF8, the question is whether to hide the representation or expose it. If you decide to expose it, there's hardly any difference between an immutable byte array and string, so it's simpler in a way to have one type that can be used both ways.
Re:Strings, bytes, runes and characters in Go by dsymonds on Wednesday October 23, 2013 @09:09PM (#6602835)
No, read the article more carefully. A Go string's internal representation is a sequence of bytes. There's nothing UTF-8 about it.
Re:Strings, bytes, runes and characters in Go by skybrian on Thursday October 24, 2013 @02:53AM (#6603744)
I understood the article just fine. It's not wrong to say that in Go, text (called strings in other languages) is nearly always represented in UTF8 format and is commonly stored in variables of type string, or sometimes []byte.

Perhaps I should have left out the word "internal" since it's exposed.

Re:Strings, bytes, runes and characters in Go by dsymonds on Thursday October 24, 2013 @06:42PM (#6608545)
Yes, "internal representation" has a specific meaning. If you had said "standard representation" or something then I would have agreed with you.
Re:Strings, bytes, runes and characters in Go by dchest on Thursday October 24, 2013 @04:41AM (#6604011)
Yes, there is: range on a string works on runes by decoding UTF-8.
Re:Strings, bytes, runes and characters in Go by dsymonds on Thursday October 24, 2013 @06:41PM (#6608533)
That has nothing to do with "a string's internal representation". That is just how a range loop is defined/implemented.