Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. module Main where
  2.  
  3. import System.Console.ANSI
  4. import System.IO
  5. import System.Environment (getArgs)
  6. import Data.List
  7. import Data.Traversable
  8. import qualified Graphics.Text.Width as VTY (wcwidth)
  9. import Data.Char
  10. import Data.Foldable
  11. import Text.Printf
  12. import qualified Data.Char.WCWidth as System (wcwidth)
  13.  
  14. isAssigned c =
  15. case generalCategory c of
  16. NotAssigned -> False
  17. Surrogate -> False
  18. Control -> False
  19. _ -> True
  20.  
  21.  
  22. main :: IO ()
  23. main = do
  24. args <- getArgs
  25. withFile (args !! 0) WriteMode $ \h ->
  26. do hSetBuffering stdout NoBuffering
  27. for_ ['\0'..'\x2FA1F'] $ \i -> do
  28. width <- if isAssigned i then show <$> charWidth i else return "-"
  29. --let width = if isAssigned i then show $ System.wcwidth i else "-"
  30. --let width = if isAssigned i then show $ VTY.wcwidth i else "-"
  31. hPrintf h "%06x\t%s\n" (ord i) width
  32.  
  33.  
  34. charWidth :: Char -> IO Int
  35. charWidth c =
  36. do printf "\r%06x: " (ord c)
  37. putChar c
  38. Just (_row, col) <- getCursorPosition0
  39. return (col - 8)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement