2-- Module : Streamly.Internal.Unicode.Utf8
3-- Copyright : (c) 2021 Composewell Technologies
4-- License : BSD-3-Clause
5-- Maintainer : streamly@composewell.com
6-- Stability : experimental
9-- XXX We can move this to stream-core/streamly-unicode-core, and provide an
10-- additional module in streamly-unicode for case conversions (because it
11-- depends on unicode-data). Or just keep all of it in streamly-unicode
12-- which will have a dependency on unicode-data.
14module Streamly.Internal.Unicode.Utf8
19 -- * Creation and elimination
26--------------------------------------------------------------------------------
28--------------------------------------------------------------------------------
30import Data.Word (Word8)
31import Streamly.Data.Array (Array)
32import System.IO.Unsafe (unsafePerformIO)
34import qualified Streamly.Data.Fold as Fold
35import qualified Streamly.Data.Stream as Stream
36import qualified Streamly.Internal.Data.Array as Array
40import qualified Streamly.Internal.Unicode.Stream as Unicode
42--------------------------------------------------------------------------------
44--------------------------------------------------------------------------------
46-- | A space efficient, packed, unboxed Unicode container.
47newtype Utf8 = Utf8 (Array Word8)
49--------------------------------------------------------------------------------
51--------------------------------------------------------------------------------
54toArray :: Utf8 -> Array Word8
55toArray (Utf8 arr) = arr
58{-# INLINEABLE pack #-}
63 $ Array.fromStreamN len $ Unicode.encodeUtf8' $ Stream.fromList s
69{-# INLINEABLE unpack #-}
70unpack :: Utf8 -> String
73 $ Stream.fold Fold.toList $ Unicode.decodeUtf8' $ Array.read $ toArray u
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