SkillAgentSearch skills...

Cgo.wchar

The cgo.wchar package is to be used with go/cgo and helps with the conversion from and to C.wchar_t and wchar_t strings (*C.wchar_t with null terminator or length int).

Install / Use

/learn @GeertJohan/Cgo.wchar
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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
}

Related Skills

View on GitHub
GitHub Stars14
CategoryDevelopment
Updated3y ago
Forks9

Languages

Go

Security Score

60/100

Audited on Nov 2, 2022

No findings