aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/GeertJohan/cgo.wchar/readme.md
blob: 1be1ef5c8884895730cc356922254318295d0911 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## 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
}
```