...

Package stringbuffer

import "github.com/Microsoft/go-winio/internal/stringbuffer"
Overview
Index

Overview ▾

Constants

Uint16BufferSize is the buffer size in the pool, chosen somewhat arbitrarily to accommodate large path strings: MAX_PATH (260) + size of volume GUID prefix (49) + null terminator = 310.

const MinWStringCap = 310

type WString

WString is a wide string buffer ([]uint16) meant for storing UTF-16 encoded strings for interacting with Win32 APIs. Sizes are specified as uint32 and not int.

It is not thread safe.

type WString struct {
    // contains filtered or unexported fields
}

func NewWString

func NewWString() *WString

NewWString returns a WString allocated from a shared pool with an initial capacity of at least MinWStringCap. Since the buffer may have been previously used, its contents are not guaranteed to be empty.

The buffer should be freed via WString.Free

func (*WString) Buffer

func (b *WString) Buffer() []uint16

Buffer returns the underlying []uint16 buffer.

func (*WString) Cap

func (b *WString) Cap() uint32

Cap returns the underlying buffer capacity.

func (*WString) Free

func (b *WString) Free()

func (*WString) Pointer

func (b *WString) Pointer() *uint16

Pointer returns a pointer to the first uint16 in the buffer. If the WString.Free has already been called, the pointer will be nil.

func (*WString) ResizeTo

func (b *WString) ResizeTo(c uint32) uint32

ResizeTo grows the buffer to at least c and returns the new capacity, freeing the previous buffer back into pool.

func (*WString) String

func (b *WString) String() string

String returns the returns the UTF-8 encoding of the UTF-16 string in the buffer.

It assumes that the data is null-terminated.