import Data.Char import Data.List import Control.Applicative import System.IO import System.Environment bool :: a -> a -> Bool -> a bool t e b = if b then t else e analyseLine :: (Int, String) -> [String] analyseLine (line, xs) | any (not . isAscii) xs = ["Line " ++ show line, " Orig: " ++ xs, " Mark: " ++ marks xs, " Char: " ++ chars xs] | otherwise = [] where marks = reverse . dropWhile isSpace . reverse . map (bool ' ' '^' . isAscii) chars = intercalate ", " . map show . filter (not . isAscii) main :: IO () main = do putStrLn "Reading from stdin" args <- getArgs hSetEncoding stdin (if "--latin1" `elem` args then latin1 else utf8) putStrLn =<< unlines . concatMap analyseLine . zip [1..] . lines <$> getContents