module Panda.Helper.Escape where import Text.ParserCombinators.Parsec import MPS hiding (parse) import Char import Prelude hiding ((.), (/), id) unicode :: Parser Char unicode = do char '&' char '#' word <- many1 digit char ';' return $ chr (read word) unescape_parser :: Parser String unescape_parser = do s <- many (unicode <|> anyChar) return $ s parse' p s = case (parse p "" s) of Left err -> err.show.error Right x -> x unescape s = parse' unescape_parser s