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 <so.qu...@gmail.com> wrote:

>
> 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" "a" "r"]
>
>
>    - Iterate through a string by "character" strings instead of runes,
>    for example:
>
> str := "foo"
> for _,char := range "bar" {
>     str += char // is a cast string(char) required?
> }
> fmt.Println(str) // print "foobar"
>
>
>
> Also what is the relationship between a rune and it's byte representation?
>
> Any additional advice for working with characters of strings would be
> appreciated as well.
>
> --
> 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.
>

-- 
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