Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 7 of 7 for EncodeRune (0.22 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 23 11:13:09 GMT 2024
    - Last Modified: Thu Apr 20 01:07:29 GMT 2023
    - 18.1K 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 23 11:13:09 GMT 2024
    - Last Modified: Thu Oct 12 14:39:08 GMT 2023
    - 21.8K bytes
    - Viewed (0)
  3. src/bufio/bufio_test.go

    	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)
    		}
    		if nbytes != size {
    			t.Fatalf("WriteRune(0x%x) expected %d, got %d", r, size, nbytes)
    		}
    Go
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Fri Feb 10 18:56:01 GMT 2023
    - 51.5K bytes
    - Viewed (0)
  4. 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 23 11:13:09 GMT 2024
    - Last Modified: Mon Feb 19 19:51:15 GMT 2024
    - 33.8K bytes
    - Viewed (0)
  5. 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 23 11:13:09 GMT 2024
    - Last Modified: Wed Jan 24 16:07:25 GMT 2024
    - 56.2K bytes
    - Viewed (0)
  6. 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 Apr 23 11:13:09 GMT 2024
    - Last Modified: Thu Apr 11 20:22:45 GMT 2024
    - 279.3K bytes
    - Viewed (0)
  7. api/go1.txt

    pkg unicode, var Zs *RangeTable
    pkg unicode/utf16, func Decode([]uint16) []int32
    pkg unicode/utf16, func DecodeRune(int32, int32) int32
    pkg unicode/utf16, func Encode([]int32) []uint16
    pkg unicode/utf16, func EncodeRune(int32) (int32, int32)
    pkg unicode/utf16, func IsSurrogate(int32) bool
    pkg unicode/utf8, const MaxRune ideal-char
    pkg unicode/utf8, const RuneError ideal-char
    pkg unicode/utf8, const RuneSelf ideal-int
    Plain Text
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Wed Aug 14 18:58:28 GMT 2013
    - 1.7M bytes
    - Viewed (1)
Back to top