Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 483 Bytes

readme.md

File metadata and controls

24 lines (19 loc) · 483 Bytes

cgo.wchar

Helps with using wchars with cgo.

Example

Example from the go.hid library:

func (dev *Device) ManufacturerString() (string, error) {
	// create WcharString
	ws := wchar.NewWcharString(100)

	// retrieve manufacturer string from hid
	res := C.hid_get_manufacturer_string(dev.hidHandle, (*C.wchar_t)(ws.Pointer()), 100)
	if res != 0 {
		return "", dev.lastError()
	}

	// get WcharString as Go string
	str := ws.GoString()

	// all done
	return str, nil
}