stringbuffer

package
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2024 License: MIT, MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const MinWStringCap = 310

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.

Variables

This section is empty.

Functions

This section is empty.

Types

type WString

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

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.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL