Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/geertjohan/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).
https://github.com/geertjohan/cgo.wchar

Last synced: 3 months ago
JSON representation

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).

Awesome Lists containing this project

README

        

## cgo.wchar

Helps with using wchars with cgo.

### Example
Example from the go.hid library:
```go
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
}
```