[plt-scheme] peek-char skip behavior

From: David T. Pierson (dtp at mindstory.com)
Date: Wed Jun 14 00:17:08 EDT 2006


What is the rationale for peek-char skipping bytes not chars?

I would like to skip chars.  I don't see a built-in function for doing
this, so here's an attempt at rolling my own.  Comments welcome.

(define (peek-char/skip-chars iport skip-k)
  (let loop ((chars-to-skip skip-k)
             (bytes-to-skip 0))
    (if (= 0 chars-to-skip)
        (peek-char iport bytes-to-skip)
        (loop (- chars-to-skip 1)
              (+ bytes-to-skip 
                 (char-utf-8-length (peek-char iport bytes-to-skip)))))))



Posted on the users mailing list.