Sorry, I did not mean to say they are restricted to UTF8. I was answering
the question "what is the relation between a rune and its byte
representation", by saying that the []byte cast of a string (assuming the
string only holds legitimate runes) is the UTF8 of the runes making it up.
The
On Mon, Oct 31, 2016 at 06:06:23PM +, 'Thomas Bushnell, BSG' via
golang-nuts wrote:
> Strings are specified to be UTF8, so if you cast a string to []byte you
> will see its UTF8 representation.
They are not. A Go string may contain arbitrary bytes. Features like
for..range or conversions to
I don't know what you mean by "characters", since you're distinguishing
them from runes. Do you mean bytes?
Strings are specified to be UTF8, so if you cast a string to []byte you
will see its UTF8 representation.
Thomas
On Sat, Oct 29, 2016 at 4:42 AM wrote:
>
> I
I know that strings are an immutable sequence of bytes, so what would be
the most idiomatic way to handle the following operations.
- Convert a string to []string (slice) or [n]string (array). Eg.
"foobar" to ["f" "o" "o" "b" "a" "r"]
- Iterate through a string and evaluate the
I understand that strings are immutable sequences of bytes and wanted to
know how to idiomatically work with the "characters" within a string.
For example how should I approach the following operations
- Convert a string to a []string (slice or array). eg. "foobar" to ["f"
"o" "o" "b"