-
--- |A list of tuples whose first entry is a regular expression
--- matching XML entities, and whose second entry is the ASCII
--- character represented by that entity.
+-- |A wrapper around the 'read' function which returns either Nothing
+-- or (Just <the thing that could be read>).
+maybe_read :: (Read a) => String -> Maybe a
+maybe_read str =
+ case (reads str) of
+ [] -> Nothing
+ ((y,_):_) -> Just y
+
+-- |Takes a unicode codepoint in decimal and returns it as a
+-- one-character string.
+entity_from_codepoint :: String -> String
+entity_from_codepoint codepoint =
+ case (maybe_read codepoint) of
+ Nothing -> ""
+ Just num -> [(chr num)]
+
+
+-- | A list of tuples whose first entry is a regular expression
+-- matching XML entities, and whose second entry is the ASCII
+-- character represented by that entity.
+--
+-- For some reason, ampersands are escaped twice in the status
+-- text. Rather than unescape everything twice, we just stick "amp"
+-- in the list again.