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 original question was confounded by asking about "characters" which is
a term that is pretty much only used by the reference in speaking of
program text; the only exception I could find is speaking of Unicode
replacement characters in talking about range iteration of strings.

My point is that the relation between a rune and its byte representation is
"UTF-8". I don't know whether the original question was using "character"
to mean "byte" (the curse of C!) or something else.

Thomas


On Mon, Oct 31, 2016 at 5:13 PM Lars Seipel <lars.sei...@gmail.com> wrote:

> On Mon, Oct 31, 2016 at 06:06:23PM +0000, '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 rune slices won't be very useful then
> (though still well-defined) but that's about it.
>
> Go source text and thus string literals are UTF-8. You might be thinking
> of those?
>
> -ls
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to