Re: [go-nuts] Re: Working with "characters" in strings

2016-10-30 Thread so . query
thanks rob!


On Saturday, October 29, 2016 at 1:24:02 PM UTC-7, Rob 'Commander' Pike 
wrote:
>
> Please read blog.golang.org/strings.
>
> -rob
>
>
> On Sat, Oct 29, 2016 at 12:08 PM,  wrote:
>
>> thanks! whats the "a:b" in this instance? did you mean s[i:i+1]? wouldn't 
>> that return a slice?
>>
>> so when iterating I'm comparing/using runes but what is the best way to 
>> refer to the ASCII values?
>>
>>
>>
>> On Saturday, October 29, 2016 at 9:36:57 AM UTC-7, Tamás Gulácsi wrote:
>>>
>>> 1. create the slice  (ss := make([]string, n)) and fill up (ss[i] = 
>>> s[a:b]), this will reuse the s's backing array, so use only the pointer to 
>>> the backing array and a length.
>>> 2. rune is a unicode code point, an alias for int32. A string is an 
>>> utf-8 encoded representation of a slice of runes: rr := []rune(s). `for _, 
>>> r := range s` will range through the runes in the string. That utf-8 
>>> encoding may use at most 4 bytes for a code point, but uses exactly 1 byte 
>>> per ASCII character.
>>
>> -- 
>> 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...@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.


Re: [go-nuts] Re: Working with "characters" in strings

2016-10-29 Thread Rob Pike
Please read blog.golang.org/strings.

-rob


On Sat, Oct 29, 2016 at 12:08 PM,  wrote:

> thanks! whats the "a:b" in this instance? did you mean s[i:i+1]? wouldn't
> that return a slice?
>
> so when iterating I'm comparing/using runes but what is the best way to
> refer to the ASCII values?
>
>
>
> On Saturday, October 29, 2016 at 9:36:57 AM UTC-7, Tamás Gulácsi wrote:
>>
>> 1. create the slice  (ss := make([]string, n)) and fill up (ss[i] =
>> s[a:b]), this will reuse the s's backing array, so use only the pointer to
>> the backing array and a length.
>> 2. rune is a unicode code point, an alias for int32. A string is an utf-8
>> encoded representation of a slice of runes: rr := []rune(s). `for _, r :=
>> range s` will range through the runes in the string. That utf-8 encoding
>> may use at most 4 bytes for a code point, but uses exactly 1 byte per ASCII
>> character.
>
> --
> 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.