- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 652 for runes (0.1 sec)
-
src/bytes/iter.go
// Unicode code points satisfying f(c). // The iterator yields the same strings that would be returned by FieldsFunc(s), // but without constructing the slice. func FieldsFuncSeq(s []byte, f func(rune) bool) iter.Seq[[]byte] { return func(yield func([]byte) bool) { start := -1 for i := 0; i < len(s); { size := 1 r := rune(s[i]) if r >= utf8.RuneSelf {
Registered: Tue Nov 05 11:13:11 UTC 2024 - Last Modified: Wed Aug 14 18:23:13 UTC 2024 - 3.7K bytes - Viewed (0) -
src/bufio/scan.go
// UTF-8-encoded rune as a token. The sequence of runes returned is // equivalent to that from a range loop over the input as a string, which // means that erroneous UTF-8 encodings translate to U+FFFD = "\xef\xbf\xbd". // Because of the Scan interface, this makes it impossible for the client to // distinguish correctly encoded replacement runes from encoding errors.
Registered: Tue Nov 05 11:13:11 UTC 2024 - Last Modified: Mon Oct 23 09:06:30 UTC 2023 - 14.2K bytes - Viewed (0) -
src/bufio/scan_test.go
} } } // Test that the rune splitter returns same sequence of runes (not bytes) as for range string. func TestScanRune(t *testing.T) { for n, test := range scanTests { buf := strings.NewReader(test) s := NewScanner(buf) s.Split(ScanRunes) var i, runeCount int var expect rune // Use a string range loop to validate the sequence of runes. for i, expect = range test { if !s.Scan() {
Registered: Tue Nov 05 11:13:11 UTC 2024 - Last Modified: Fri Sep 22 16:22:42 UTC 2023 - 14.3K bytes - Viewed (0) -
src/bytes/bytes_test.go
t.Errorf("%s(%q) = %q; want %q", funcName, tc.in, actual, tc.out) } } } func tenRunes(r rune) string { runes := make([]rune, 10) for i := range runes { runes[i] = r } return string(runes) } // User-defined self-inverse mapping function func rot13(r rune) rune { const step = 13 if r >= 'a' && r <= 'z' { return ((r - 'a' + step) % 26) + 'a' }
Registered: Tue Nov 05 11:13:11 UTC 2024 - Last Modified: Mon Aug 19 19:09:04 UTC 2024 - 61.2K bytes - Viewed (0) -
src/bytes/bytes.go
// returning nil instead of empty slice if all spaces. return nil } return s[start:stop] } // Runes interprets s as a sequence of UTF-8-encoded code points. // It returns a slice of runes (Unicode code points) equivalent to s. func Runes(s []byte) []rune { t := make([]rune, utf8.RuneCount(s)) i := 0 for len(s) > 0 { r, l := utf8.DecodeRune(s) t[i] = r i++ s = s[l:] }
Registered: Tue Nov 05 11:13:11 UTC 2024 - Last Modified: Tue Sep 03 20:55:15 UTC 2024 - 35.6K bytes - Viewed (0) -
src/bytes/example_test.go
fmt.Println(bytes.LastIndexFunc([]byte("go gopher!"), unicode.IsNumber)) // Output: // 8 // 9 // -1 } func ExampleMap() { rot13 := func(r rune) rune { switch { case r >= 'A' && r <= 'Z': return 'A' + (r-'A'+13)%26 case r >= 'a' && r <= 'z': return 'a' + (r-'a'+13)%26 } return r }
Registered: Tue Nov 05 11:13:11 UTC 2024 - Last Modified: Wed Aug 07 17:22:36 UTC 2024 - 14.9K bytes - Viewed (0) -
src/bytes/buffer.go
// included to match [bufio.Writer]'s WriteRune. The buffer is grown as needed; // if it becomes too large, WriteRune will panic with [ErrTooLarge]. func (b *Buffer) WriteRune(r rune) (n int, err error) { // Compare as uint32 to correctly handle negative runes. if uint32(r) < utf8.RuneSelf { b.WriteByte(byte(r)) return 1, nil } b.lastRead = opInvalid m, ok := b.tryGrowByReslice(utf8.UTFMax) if !ok {
Registered: Tue Nov 05 11:13:11 UTC 2024 - Last Modified: Tue Oct 29 16:47:05 UTC 2024 - 15.7K bytes - Viewed (0) -
src/bufio/bufio_test.go
} } func TestReadWriteRune(t *testing.T) { const NRune = 1000 byteBuf := new(bytes.Buffer) w := NewWriter(byteBuf) // Write the runes out using WriteRune buf := make([]byte, utf8.UTFMax) for r := rune(0); r < NRune; r++ { size := utf8.EncodeRune(buf, r) nbytes, err := w.WriteRune(r) if err != nil { t.Fatalf("WriteRune(0x%x) error: %s", r, err) }
Registered: Tue Nov 05 11:13:11 UTC 2024 - Last Modified: Fri Nov 01 21:52:12 UTC 2024 - 51.6K bytes - Viewed (0) -
src/bytes/buffer_test.go
} } } func TestWriteInvalidRune(t *testing.T) { // Invalid runes, including negative ones, should be written as // utf8.RuneError. for _, r := range []rune{-1, utf8.MaxRune + 1} { var buf Buffer buf.WriteRune(r) check(t, fmt.Sprintf("TestWriteInvalidRune (%d)", r), &buf, "\uFFFD") } }
Registered: Tue Nov 05 11:13:11 UTC 2024 - Last Modified: Tue Sep 03 20:55:15 UTC 2024 - 18.6K bytes - Viewed (0) -
src/bufio/bufio.go
b.lastRuneSize = -1 return nil } // ReadRune reads a single UTF-8 encoded Unicode character and returns the // rune and its size in bytes. If the encoded rune is invalid, it consumes one byte // and returns unicode.ReplacementChar (U+FFFD) with a size of 1. func (b *Reader) ReadRune() (r rune, size int, err error) { for b.r+utf8.UTFMax > b.w && !utf8.FullRune(b.buf[b.r:b.w]) && b.err == nil && b.w-b.r < len(b.buf) {
Registered: Tue Nov 05 11:13:11 UTC 2024 - Last Modified: Thu Oct 12 14:39:08 UTC 2023 - 21.8K bytes - Viewed (0)