aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorross <unknown>2005-01-10 19:18:22 +0000
committerross <unknown>2005-01-10 19:18:22 +0000
commitff11fc2c46c2611a06ab7b84b8d502be88519d01 (patch)
tree32df459ac47db6f3ab4ca9e6af963b600b2d8710
parent47870837e855daea82c09ca59315a048fc8438a6 (diff)
[haddock @ 2005-01-10 19:18:22 by ross]
Render non-ASCII characters using numeric character references, to simplify charset issues. There's a META tag saying the charset is UTF-8, but GHC outputs characters as raw bytes. Ideally we need an encoding on the input side too, primarily in comments, because source files containing non-ASCII characters aren't portable between locales.
-rw-r--r--src/Html.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Html.hs b/src/Html.hs
index f4efa218..ae14c9ae 100644
--- a/src/Html.hs
+++ b/src/Html.hs
@@ -19,6 +19,9 @@ module Html (
import qualified BlockTable as BT
+import Data.Char (isAscii, ord)
+import Numeric (showHex)
+
infixr 2 +++ -- combining Html
infixr 7 << -- nesting Html
infixl 8 ! -- adding optional arguments
@@ -152,7 +155,9 @@ stringToHtmlString = concatMap fixChar
fixChar '>' = "&gt;"
fixChar '&' = "&amp;"
fixChar '"' = "&quot;"
- fixChar c = [c]
+ fixChar c
+ | isAscii c = [c]
+ | otherwise = "&#x" ++ showHex (ord c) ";"
-- ---------------------------------------------------------------------------
-- Classes