1-- Copyright 2009 Corey O'Connor
2{-# OPTIONS_GHC -D_XOPEN_SOURCE -fno-cse #-}
3{-# LANGUAGE ForeignFunctionInterface #-}
4{-# INCLUDE <wchar.h> #-}
5module Codec.Binary.UTF8.Width ( wcwidth
11import Foreign.C.String
12import Foreign.Storable
14import Numeric ( showHex )
16import System.IO.Unsafe
19wcwidth c = unsafePerformIO (withCWString [c] $ \ws -> do
21 putStr $ "wcwidth(0x" ++ showHex (fromEnum wc) "" ++ ")"
22 w <- wcwidth' wc >>= return . fromIntegral
23 putStrLn $ " -> " ++ show w
26{-# NOINLINE wcwidth #-}
28foreign import ccall "mk_wcwidth" wcwidth' :: CWchar -> IO CInt
30wcswidth :: String -> Int
31wcswidth str = sum $ map wcwidth str
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list