Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 21 for Runes (0.15 sec)

  1. 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.
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Mon Oct 23 09:06:30 GMT 2023
    - 14.2K bytes
    - Viewed (0)
  2. 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
    			}
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Fri Sep 22 16:22:42 GMT 2023
    - 14.3K bytes
    - Viewed (0)
  3. 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++
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Mon Feb 19 19:51:15 GMT 2024
    - 33.8K bytes
    - Viewed (0)
  4. 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' {
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Wed Jan 24 16:07:25 GMT 2024
    - 56.2K bytes
    - Viewed (0)
  5. 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()
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Fri Feb 10 18:56:01 GMT 2023
    - 51.5K bytes
    - Viewed (0)
  6. 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)
    	}
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Fri Oct 13 17:10:31 GMT 2023
    - 15.7K bytes
    - Viewed (0)
  7. src/bufio/bufio.go

    }
    
    // WriteRune writes a single Unicode code point, returning
    // the number of bytes written and any error.
    func (b *Writer) WriteRune(r rune) (size int, err error) {
    	// Compare as uint32 to correctly handle negative runes.
    	if uint32(r) < utf8.RuneSelf {
    		err = b.WriteByte(byte(r))
    		if err != nil {
    			return 0, err
    		}
    		return 1, nil
    	}
    	if b.err != nil {
    		return 0, b.err
    	}
    	n := b.Available()
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Thu Oct 12 14:39:08 GMT 2023
    - 21.8K bytes
    - Viewed (0)
  8. 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'
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Mon Mar 04 15:54:40 GMT 2024
    - 15K bytes
    - Viewed (1)
  9. 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)
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Fri Apr 26 13:31:36 GMT 2024
    - 18.6K bytes
    - Viewed (0)
  10. 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.
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Fri Oct 13 18:36:46 GMT 2023
    - 27.7K bytes
    - Viewed (0)
Back to top