Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 5 of 5 for EncodeRune (7.89 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)
  4. src/bytes/bytes_test.go

    			}
    		}
    		buf[n-1] = '\x00'
    	}
    }
    
    func bmIndexRune(index func([]byte, rune) int) func(b *testing.B, n int) {
    	return func(b *testing.B, n int) {
    		buf := bmbuf[0:n]
    		utf8.EncodeRune(buf[n-3:], '世')
    		for i := 0; i < b.N; i++ {
    			j := index(buf, '世')
    			if j != n-3 {
    				b.Fatal("bad index", j)
    			}
    		}
    		buf[n-3] = '\x00'
    		buf[n-2] = '\x00'
    		buf[n-1] = '\x00'
    	}
    }
    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. doc/go_spec.html

    integer-to-string conversions as potential errors.
    Library functions such as
    <a href="/pkg/unicode/utf8#AppendRune"><code>utf8.AppendRune</code></a> or
    <a href="/pkg/unicode/utf8#EncodeRune"><code>utf8.EncodeRune</code></a>
    should be used instead.
    </li>
    </ol>
    
    <h4 id="Conversions_from_slice_to_array_or_array_pointer">Conversions from slice to array or array pointer</h4>
    
    <p>
    HTML
    - Registered: Tue May 07 11:14:38 GMT 2024
    - Last Modified: Thu May 02 22:43:51 GMT 2024
    - 279.6K bytes
    - Viewed (0)
Back to top