(length (C-> GdkEvent "GdkEvent key length"))
(state (C-> GdkEvent "GdkEvent key state"))
(keyval (C-> GdkEvent "GdkEvent key keyval")))
- (let ((string (utf8->string (c-peek-cstring alien)))
+ (let ((string (bytes->string (c-peek-cstring alien)))
(char-bits (gdk-key-state->char-bits state)))
(cond ((zero? (string-length string))
(cond ((fix:= length 1)
(define (note-error)
(let* ((gerror (C-> gerror* "* GError"))
(message (or (and (not (alien-null? gerror))
- (utf8->string
+ (bytes->string
(c-peek-cstring
(C-> gerror "GError message"))))
"GError pointer not set.")))
(declare (ignore clipboard))
(if (alien-null? char*)
(queue! queue #t)
- (queue! queue (utf8->string (c-peek-cstring char*)))))))
+ (queue! queue (bytes->string (c-peek-cstring char*)))))))
(define (queue! queue value)
(thread-queue/queue! queue value)
(C-> GdkEvent "GdkEvent key keyval")))
(text (let ((alien (make-alien '|gchar|)))
(C-> GdkEvent "GdkEvent key string" alien)
- (utf8->string (c-peek-cstring alien)))))
+ (bytes->string (c-peek-cstring alien)))))
(cat "Keyval: "keyval" Text: "text"\n")))
(else
#f))))
(map (lambda (elt)
(let ((alien (weak-car elt)))
(if (eq? 'uchar (alien/ctype alien))
- (utf8->string (c-peek-cstring alien))
+ (bytes->string (c-peek-cstring alien))
alien)))
(access malloced-aliens ffi))))))
\ No newline at end of file
(define (error-if-gerror* gerror* message . data)
(let ((gerror (C-> gerror* "* GError")))
(if (not (alien-null? gerror))
- (let ((errmsg-bv (c-peek-cstring (C-> gerror "GError message"))))
+ (let ((errmsg-bytes (c-peek-cstring (C-> gerror "GError message"))))
(without-interruption
(lambda ()
(C->= gerror* "* GError" 0)
(C-call "g_error_free" gerror)))
- (apply error message (utf8->string errmsg-bv) data)))))
+ (apply error message (bytes->string errmsg-bytes) data)))))
(define-class (<gtk-css-provider> (constructor ()))
(<gobject-with-gerror*>))
(guarantee-gtk-label label 'gtk-label-get-text)
(let ((retval (make-alien '|gchar|)))
(C-call "gtk_label_get_text" retval (gobject-alien label))
- (utf8->string (c-peek-cstring retval))))
+ (bytes->string (c-peek-cstring retval))))
(define (gtk-label-set-text label string)
(guarantee-gtk-label label 'gtk-label-set-text)
(set-color-green! color green)
(set-color-blue! color blue)
(set-color-alpha! color alpha)
- color))
\ No newline at end of file
+ color))
+
+(declare (integrate-operator bytes->string))
+(define (bytes->string bytes)
+ (cond ((string? bytes)
+ bytes)
+ ((bytevector? bytes)
+ (utf8->string bytes))
+ (else
+ (error:wrong-type-argument bytes "a string or bytevector"))))
\ No newline at end of file
(let loop ((i 0)(args '()))
(if (fix:< i new-argc)
(loop (fix:1+ i)
- (cons (utf8->string
+ (cons (bytes->string
(c-peek-cstringp! vector-scan))
args))
(reverse! args)))))