From a6101a3d02277df41c3c130e4bf87c0d92af0260 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 30 May 2004 12:51:29 +0000 Subject: [PATCH] . original commit: 90fa4e9e9c93ef89f3e36ecee83c591fe1037610 --- collects/mzlib/foreign.ss | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/collects/mzlib/foreign.ss b/collects/mzlib/foreign.ss index 60e2f29..1b4f7d7 100644 --- a/collects/mzlib/foreign.ss +++ b/collects/mzlib/foreign.ss @@ -214,13 +214,17 @@ ;; utf-16 type (note: these do not use #f as NULL). (provide _string/ucs-4 _string/utf-16) -;; 8-bit string encodings +;; 8-bit string encodings (#f is NULL) +(define (false-or-op op) (lambda (x) (and x (op x)))) (define* _string/utf-8 - (make-ffi-type _bytes string->bytes/utf-8 bytes->string/utf-8)) + (make-ffi-type _bytes + (false-or-op string->bytes/utf-8) (false-or-op bytes->string/utf-8))) (define* _string/locale - (make-ffi-type _bytes string->bytes/locale bytes->string/locale)) + (make-ffi-type _bytes + (false-or-op string->bytes/locale) (false-or-op bytes->string/locale))) (define* _string/latin-1 - (make-ffi-type _bytes string->bytes/latin-1 bytes->string/latin-1)) + (make-ffi-type _bytes + (false-or-op string->bytes/latin-1) (false-or-op bytes->string/latin-1))) ;; A generic _string type that usually does the right thing via a parameter (define* default-_string-type