- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 22 for Runes (0.08 sec)
-
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() { break }
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/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/bytes/bytes_test.go
} if !Equal(actual, tc.out) { 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' {
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/iter.go
line, s = s[:i+1], s[i+1:] } else { line, s = s, nil } if !yield(line[:len(line):len(line)]) { return } } return } } // explodeSeq returns an iterator over the runes in s. func explodeSeq(s []byte) iter.Seq[[]byte] { return func(yield func([]byte) bool) { for len(s) > 0 { _, size := utf8.DecodeRune(s) if !yield(s[:size:size]) { return } s = s[size:] }
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/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++
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
} func ExampleReplaceAll() { fmt.Printf("%s\n", bytes.ReplaceAll([]byte("oink oink oink"), []byte("oink"), []byte("moo"))) // Output: // moo moo moo } func ExampleRunes() { rs := bytes.Runes([]byte("go gopher")) for _, r := range rs { fmt.Printf("%#U\n", r) } // Output: // U+0067 'g' // U+006F 'o' // U+0020 ' ' // U+0067 'g' // U+006F 'o' // U+0070 'p' // U+0068 'h'
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/bufio/bufio_test.go
t.Errorf("#%d: got error %v; want EOF", rno, err) } } } // Test that UnreadRune fails if the preceding operation was not a ReadRune. func TestUnreadRuneError(t *testing.T) { buf := make([]byte, 3) // All runes in this test are 3 bytes long r := NewReader(&StringReader{data: []string{"日本語日本語日本語"}}) if r.UnreadRune() == nil { t.Error("expected error on UnreadRune from fresh buffer") } _, _, err := r.ReadRune()
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.go
// 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 { m = b.grow(utf8.UTFMax) }
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/bytes/buffer_test.go
t.Fatalf("ReadRune(%U) after UnreadRune got %U,%d not %U,%d (err=%s)", r, r2, nbytes, r, size, err) } } } 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)
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/archive/zip/reader.go
switch { case !utf8Valid1 || !utf8Valid2: // Name and Comment definitely not UTF-8. f.NonUTF8 = true case !utf8Require1 && !utf8Require2: // Name and Comment use only single-byte runes that overlap with UTF-8. f.NonUTF8 = false default: // Might be UTF-8, might be some other encoding; preserve existing flag. // Some ZIP writers use UTF-8 encoding without setting the UTF-8 flag.
Registered: Tue Nov 05 11:13:11 UTC 2024 - Last Modified: Sat Aug 03 01:05:29 UTC 2024 - 28.1K bytes - Viewed (0)