app: [macOS,iOS] don't use [NSString UTF8String]

UTF8String is lossy in the presence of nul (\x00) runes.

While here, don't CFRelease the input to nsstringToString; leave it
up to the caller.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-02-09 17:27:26 +01:00
parent b28307baeb
commit ef9e4071e7
5 changed files with 50 additions and 40 deletions
+5 -3
View File
@@ -226,9 +226,9 @@ func onDeleteBackward(view C.CFTypeRef) {
}
//export onText
func onText(view C.CFTypeRef, str *C.char) {
func onText(view, str C.CFTypeRef) {
w := views[view]
w.w.EditorInsert(C.GoString(str))
w.w.EditorInsert(nsstringToString(str))
}
//export onTouch
@@ -259,7 +259,9 @@ func onTouch(last C.int, view, touchRef C.CFTypeRef, phase C.NSInteger, x, y C.C
}
func (w *window) ReadClipboard() {
content := nsstringToString(C.readClipboard())
cstr := C.readClipboard()
defer C.CFRelease(cstr)
content := nsstringToString(cstr)
w.w.Event(clipboard.Event{Text: content})
}