;;;; string-hexadecimal.scm -*- Hen -*- ;;;; Kon Lovett, Aug '10 (module string-hexadecimal (;export string->hex *string->hex) (import scheme chicken) (import (only lolevel number-of-bytes) (only to-hex str_to_hex) (only type-checks check-natural-fixnum check-string)) (require-library lolevel to-hex type-checks) (declare (bound-to-procedure ##sys#signal-hook)) ;; (define (string->hex str #!optional (start 0) (end #f)) (check-string 'string->hex str) (check-natural-fixnum 'string->hex start 'start) (let ((end (or (and end (check-natural-fixnum 'string->hex end 'end)) (number-of-bytes str)))) (unless (<= start end) (##sys#signal-hook #:bounds-error 'string->hex "illegal subvector specification" start end)) (*string->hex str start end) ) ) (define (*string->hex str start end) (let ((len (fx- end start))) (if (fx= 0 len) "" (str_to_hex (make-string (fx* len 2)) str start len) ) ) ) ) ;module string-hexadecimal