> The 'read' procedure that looks for the encoding declaration should be a > special reader that's much simpler than the normal Scheme reader and > handles encoding errors gracefully [...] Here's a quick sketch of the idea implemented in 100 lines of R7RS Scheme: <https://github.com/lassik/scheme-encoding-declaration> It reads up to 1000 bytes from the file into a bytevector and reads the first Scheme form from that bytevector, interpreting the bytes as an ASCII superset. If there are any errors, it simply returns #f.