Added string->bytevector and bytevector->string as per bug 245983.
This commit is contained in:
parent
8423610f45
commit
f6957b91c2
|
@ -4,7 +4,7 @@
|
||||||
angle make-polar
|
angle make-polar
|
||||||
bitwise-copy-bit-field bitwise-reverse-bit-field
|
bitwise-copy-bit-field bitwise-reverse-bit-field
|
||||||
bitwise-rotate-bit-field bitwise-if fxreverse-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-binary-input/output-port
|
||||||
make-custom-textual-input/output-port
|
make-custom-textual-input/output-port
|
||||||
open-file-input/output-port output-port-buffer-mode
|
open-file-input/output-port output-port-buffer-mode
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
angle make-polar
|
angle make-polar
|
||||||
bitwise-copy-bit-field bitwise-reverse-bit-field
|
bitwise-copy-bit-field bitwise-reverse-bit-field
|
||||||
bitwise-rotate-bit-field bitwise-if fxreverse-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-binary-input/output-port
|
||||||
make-custom-textual-input/output-port
|
make-custom-textual-input/output-port
|
||||||
open-file-input/output-port output-port-buffer-mode
|
open-file-input/output-port output-port-buffer-mode
|
||||||
|
@ -56,7 +56,6 @@
|
||||||
|
|
||||||
(not-yet
|
(not-yet
|
||||||
;;; should be implemented
|
;;; should be implemented
|
||||||
bytevector->string string->bytevector
|
|
||||||
string-downcase string-titlecase string-upcase
|
string-downcase string-titlecase string-upcase
|
||||||
angle make-polar
|
angle make-polar
|
||||||
bitwise-if
|
bitwise-if
|
||||||
|
|
|
@ -16,9 +16,11 @@
|
||||||
|
|
||||||
(library (ikarus transcoders)
|
(library (ikarus transcoders)
|
||||||
(export string->utf8 utf8->string string->utf16 string->utf32
|
(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
|
(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 $strings)
|
||||||
(ikarus system $bytevectors)
|
(ikarus system $bytevectors)
|
||||||
(ikarus system $fx)
|
(ikarus system $fx)
|
||||||
|
@ -584,4 +586,26 @@
|
||||||
[(bv endianness em?)
|
[(bv endianness em?)
|
||||||
($utf32->string 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))
|
||||||
|
)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
1530
|
1531
|
||||||
|
|
Loading…
Reference in New Issue