Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 3 of 3 for EncodeRune (0.17 sec)

  1. src/bytes/buffer_test.go

    func TestRuneIO(t *testing.T) {
    	const NRune = 1000
    	// Built a test slice while we write the data
    	b := make([]byte, utf8.UTFMax*NRune)
    	var buf Buffer
    	n := 0
    	for r := rune(0); r < NRune; r++ {
    		size := utf8.EncodeRune(b[n:], r)
    		nbytes, err := buf.WriteRune(r)
    		if err != nil {
    			t.Fatalf("WriteRune(%U) error: %s", r, err)
    		}
    		if nbytes != size {
    			t.Fatalf("WriteRune(%U) expected %d, got %d", r, size, nbytes)
    		}
    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)
  2. src/bufio/bufio.go

    		if b.Flush(); b.err != nil {
    			return 0, b.err
    		}
    		n = b.Available()
    		if n < utf8.UTFMax {
    			// Can only happen if buffer is silly small.
    			return b.WriteString(string(r))
    		}
    	}
    	size = utf8.EncodeRune(b.buf[b.n:], r)
    	b.n += size
    	return size, nil
    }
    
    // WriteString writes a string.
    // It returns the number of bytes written.
    // If the count is less than len(s), it also returns an error explaining
    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)
  3. src/bytes/bytes.go

    			if r1 == utf8.RuneError {
    				return i
    			}
    			i += n
    		}
    		return -1
    	case !utf8.ValidRune(r):
    		return -1
    	default:
    		var b [utf8.UTFMax]byte
    		n := utf8.EncodeRune(b[:], r)
    		return Index(s, b[:n])
    	}
    }
    
    // IndexAny interprets s as a sequence of UTF-8-encoded Unicode code points.
    // It returns the byte index of the first occurrence in s of any of the Unicode
    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)
Back to top