<div dir="ltr">Yes, I think file/sha1 is the right place.<div><br></div><div>Thanks!<br><div><br></div><div>Robby</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 11, 2013 at 3:26 PM, David Vanderson <span dir="ltr"><<a href="mailto:david.vanderson@gmail.com" target="_blank">david.vanderson@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thank you Stephen and Tony for your examples. I found the following private function in db/private/mysql/connection.<u></u>rkt:<br>
<br>
(define (hex-string->bytes s)<br>
(define (hex-digit->int c)<br>
(let ([c (char->integer c)])<br>
(cond [(<= (char->integer #\0) c (char->integer #\9))<br>
(- c (char->integer #\0))]<br>
[(<= (char->integer #\a) c (char->integer #\f))<br>
(+ 10 (- c (char->integer #\a)))]<br>
[(<= (char->integer #\A) c (char->integer #\F))<br>
(+ 10 (- c (char->integer #\A)))])))<br>
(unless (and (string? s) (even? (string-length s))<br>
(regexp-match? #rx"[0-9a-zA-Z]*" s))<br>
(raise-type-error 'hex-string->bytes<br>
"string containing an even number of hexadecimal digits" s))<br>
(let* ([c (quotient (string-length s) 2)]<br>
[b (make-bytes c)])<br>
(for ([i (in-range c)])<br>
(let ([high (hex-digit->int (string-ref s (+ i i)))]<br>
[low (hex-digit->int (string-ref s (+ i i 1)))])<br>
(bytes-set! b i (+ (arithmetic-shift high 4) low))))<br>
b))<br>
<br>
<br>
Can this function be exported? I'm willing to make a patch with docs and tests - is file/sha1 the right place?<div class="HOEnZb"><div class="h5"><br>
<br>
Thanks,<br>
Dave<br>
<br>
_________________________<br>
Racket Developers list:<br>
<a href="http://lists.racket-lang.org/dev" target="_blank">http://lists.racket-lang.org/<u></u>dev</a><br>
</div></div></blockquote></div><br></div>