diff --git a/scheme/ikarus.not-yet-implemented.ss b/scheme/ikarus.not-yet-implemented.ss index 5ffe6e8..ad4fd4e 100644 --- a/scheme/ikarus.not-yet-implemented.ss +++ b/scheme/ikarus.not-yet-implemented.ss @@ -4,7 +4,7 @@ angle make-polar bitwise-copy-bit-field bitwise-reverse-bit-field bitwise-rotate-bit-field bitwise-if fxreverse-bit-field - fxrotate-bit-field bytevector->string string->bytevector + fxrotate-bit-field make-custom-binary-input/output-port make-custom-textual-input/output-port open-file-input/output-port output-port-buffer-mode @@ -20,7 +20,7 @@ angle make-polar bitwise-copy-bit-field bitwise-reverse-bit-field bitwise-rotate-bit-field bitwise-if fxreverse-bit-field - fxrotate-bit-field bytevector->string string->bytevector + fxrotate-bit-field make-custom-binary-input/output-port make-custom-textual-input/output-port open-file-input/output-port output-port-buffer-mode @@ -56,7 +56,6 @@ (not-yet ;;; should be implemented - bytevector->string string->bytevector string-downcase string-titlecase string-upcase angle make-polar bitwise-if diff --git a/scheme/ikarus.unicode-conversion.ss b/scheme/ikarus.unicode-conversion.ss index 0d0f9cf..162481f 100644 --- a/scheme/ikarus.unicode-conversion.ss +++ b/scheme/ikarus.unicode-conversion.ss @@ -16,9 +16,11 @@ (library (ikarus transcoders) (export string->utf8 utf8->string string->utf16 string->utf32 - utf16->string utf32->string) + utf16->string utf32->string string->bytevector + bytevector->string) (import (except (ikarus) string->utf8 utf8->string string->utf16 - utf16->string string->utf32 utf32->string) + utf16->string string->utf32 utf32->string + string->bytevector bytevector->string) (ikarus system $strings) (ikarus system $bytevectors) (ikarus system $fx) @@ -584,4 +586,26 @@ [(bv endianness em?) ($utf32->string bv endianness em?)]))) - ) + + (define (bytevector->string bv t) + (define who 'bytevector->string) + (unless (bytevector? bv) + (die who "not a bytevector" bv)) + (unless (transcoder? t) + (die who "not a transcoder" t)) + (call-with-port (open-bytevector-input-port bv t) + (lambda (tcip) + (let ([r (get-string-all tcip)]) + (if (eof-object? r) "" r))))) + + (define (string->bytevector str t) + (define who 'string->bytevector) + (unless (string? str) + (die who "not a string" str)) + (unless (transcoder? t) + (die who "not a transcoder" t)) + (call-with-bytevector-output-port + (lambda (tcop) + (put-string tcop str)) + t)) +) diff --git a/scheme/last-revision b/scheme/last-revision index e8c1952..45ff3ac 100644 --- a/scheme/last-revision +++ b/scheme/last-revision @@ -1 +1 @@ -1530 +1531