From 240e259ce2dbae36b42efebaaf09d90aa7ffe086 Mon Sep 17 00:00:00 2001 From: David Lichteblau Date: Sun, 13 Apr 2008 20:57:00 +0200 Subject: [PATCH] Output encoding support, using Babel --- src/parse/unparse.lisp | 64 +++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/parse/unparse.lisp b/src/parse/unparse.lisp index 4f93ad3..b0cc805 100644 --- a/src/parse/unparse.lisp +++ b/src/parse/unparse.lisp @@ -146,7 +146,7 @@ (defmethod hax:characters ((sink sink) data) (let ((y (sink-ystream sink))) (if (find (caar (stack sink)) '("script" "style") :test 'equalp) - (write-rod data (sink-ystream sink)) + (ystream-write-escapable-rod data (sink-ystream sink)) (loop for c across data do (unparse-datachar-readable c y))))) (defmethod hax:unescaped ((sink sink) data) @@ -170,55 +170,55 @@ do (cond ((rune= c #/&) (if (and (< i (length str)) (rune= (rune str i) #/{)) - (write-rune c y) - (write-rod '#.(string-rod "&") y))) - ((rune= c #/\") (write-rod '#.(string-rod """) y)) - ((rune= c #/U+000A) (write-rod '#.(string-rod " ") y)) - ((rune= c #/U+000D) (write-rod '#.(string-rod " ") y)) + (ystream-write-rune c y) + (ystream-write-rod '#.(string-rod "&") y))) + ((rune= c #/\") (ystream-write-rod '#.(string-rod """) y)) + ((rune= c #/U+000A) (ystream-write-rod '#.(string-rod " ") y)) + ((rune= c #/U+000D) (ystream-write-rod '#.(string-rod " ") y)) (t - (write-rune c y)))))) + (ystream-write-escapable-rune c y)))))) (defun unparse-datachar (c ystream) - (cond ((rune= c #/&) (write-rod '#.(string-rod "&") ystream)) - ((rune= c #/<) (write-rod '#.(string-rod "<") ystream)) - ((rune= c #/>) (write-rod '#.(string-rod ">") ystream)) - ((rune= c #/\") (write-rod '#.(string-rod """) ystream)) - ((rune= c #/U+0009) (write-rod '#.(string-rod " ") ystream)) - ((rune= c #/U+000A) (write-rod '#.(string-rod " ") ystream)) - ((rune= c #/U+000D) (write-rod '#.(string-rod " ") ystream)) + (cond ((rune= c #/&) (ystream-write-rod '#.(string-rod "&") ystream)) + ((rune= c #/<) (ystream-write-rod '#.(string-rod "<") ystream)) + ((rune= c #/>) (ystream-write-rod '#.(string-rod ">") ystream)) + ((rune= c #/\") (ystream-write-rod '#.(string-rod """) ystream)) + ((rune= c #/U+0009) (ystream-write-rod '#.(string-rod " ") ystream)) + ((rune= c #/U+000A) (ystream-write-rod '#.(string-rod " ") ystream)) + ((rune= c #/U+000D) (ystream-write-rod '#.(string-rod " ") ystream)) (t - (write-rune c ystream)))) + (ystream-write-escapable-rune c ystream)))) (defun unparse-datachar-readable (c ystream) - (cond ((rune= c #/&) (write-rod '#.(string-rod "&") ystream)) - ((rune= c #/<) (write-rod '#.(string-rod "<") ystream)) - ((rune= c #/>) (write-rod '#.(string-rod ">") ystream)) - ((rune= c #/\") (write-rod '#.(string-rod """) ystream)) - ((rune= c #/U+000D) (write-rod '#.(string-rod " ") ystream)) + (cond ((rune= c #/&) (ystream-write-rod '#.(string-rod "&") ystream)) + ((rune= c #/<) (ystream-write-rod '#.(string-rod "<") ystream)) + ((rune= c #/>) (ystream-write-rod '#.(string-rod ">") ystream)) + ((rune= c #/\") (ystream-write-rod '#.(string-rod """) ystream)) + ((rune= c #/U+000D) (ystream-write-rod '#.(string-rod " ") ystream)) (t - (write-rune c ystream)))) + (ystream-write-escapable-rune c ystream)))) (defun unparse-dtd-string (str sink) (let ((y (sink-ystream sink))) (loop for rune across str do (unparse-dtd-char rune y)))) (defun unparse-dtd-char (c ystream) - (cond ((rune= c #/%) (write-rod '#.(string-rod "%") ystream)) - ((rune= c #/&) (write-rod '#.(string-rod "&") ystream)) - ((rune= c #/<) (write-rod '#.(string-rod "<") ystream)) - ((rune= c #/>) (write-rod '#.(string-rod ">") ystream)) - ((rune= c #/\") (write-rod '#.(string-rod """) ystream)) - ((rune= c #/U+0009) (write-rod '#.(string-rod " ") ystream)) - ((rune= c #/U+000A) (write-rod '#.(string-rod " ") ystream)) - ((rune= c #/U+000D) (write-rod '#.(string-rod " ") ystream)) + (cond ((rune= c #/%) (ystream-write-rod '#.(string-rod "%") ystream)) + ((rune= c #/&) (ystream-write-rod '#.(string-rod "&") ystream)) + ((rune= c #/<) (ystream-write-rod '#.(string-rod "<") ystream)) + ((rune= c #/>) (ystream-write-rod '#.(string-rod ">") ystream)) + ((rune= c #/\") (ystream-write-rod '#.(string-rod """) ystream)) + ((rune= c #/U+0009) (ystream-write-rod '#.(string-rod " ") ystream)) + ((rune= c #/U+000A) (ystream-write-rod '#.(string-rod " ") ystream)) + ((rune= c #/U+000D) (ystream-write-rod '#.(string-rod " ") ystream)) (t - (write-rune c ystream)))) + (ystream-write-escapable-rune c ystream)))) (defun %write-rune (c sink) - (write-rune c (sink-ystream sink))) + (ystream-write-rune c (sink-ystream sink))) (defun %write-rod (r sink) - (write-rod r (sink-ystream sink))) + (ystream-write-rod r (sink-ystream sink))) ;;;; convenience functions for PTless HTML serialization -- 2.11.4.GIT