[Home]ISO 8859-1/Scheme source

HomePage | ISO 8859-1 | Recent Changes | Preferences

This Scheme code was used to generate the table in ISO 8859-1.

;;; ISO 8859-1 table maker
;;; Written by Damian Yerrick
;;; Released into the public domain

(define hexdigits "0123456789ABCDEF")

(define print-iso-8859-1-chart

  (let ((ascii-line
	 (lambda (init-ascii fp)
	   ;; table row header
	   (display "<tr><th>" fp)
	   (display (string-ref hexdigits
				(floor (/ init-ascii 16)))
		    fp)
	   (display "x</th>" fp)
	   (let loop ((c init-ascii)
		      (end (+ init-ascii 16)))
	     (display "<td>" fp)

	     ;; print the character, escaping SGML-special and non-ASCII characters
	     (cond
	       ((= c 60) (display "<" fp))
	       ((= c 62) (display ">" fp))
	       ((= c 38) (display "&" fp))
	       ((>= c 128)
		(display "&#" fp)
		(display c fp)
		(display ";" fp))
	       (else (write-char (integer->char c) fp)))
	     (display "</td>" fp)
	     (if (< (+ c 1) end)
		 (loop (+ c 1) end)))
	   (display "</tr>" fp)
	   (newline fp)
	   )))
    (lambda fpl
      (let ((fp (if (null? fpl)
		    (current-output-port)
		    (car fpl))))

	;; print column headings
	(display "<table><tr><th></th>")
	(let loop ((c 0))
	  (display "<th>x" fp)
	  (write-char (string-ref hexdigits c) fp)
	  (display "</th>" fp)
	  (if (< (+ c 1) 16)
	      (loop (+ c 1))))
	(display "</tr>" fp)
	(newline fp)

	;; print the body of the table
	(let loop ((c 32))
	  (ascii-line c fp)
	  (cond
	   ((= c 112) (loop (+ c 48)))      ;skip 80 to 9f for now
	   ((< (+ c 16) 256) (loop (+ c 16)))))
	(display "</table>" fp)
	(newline fp)))))


HomePage | ISO 8859-1 | Recent Changes | Preferences
This page is read-only | View other revisions
Last edited December 8, 2001 1:13 pm by 137.112.129.xxx (diff)
Search: