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