File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ module Data.Text.Foreign
1515 -- * Interoperability with native code
1616 -- $interop
1717 I8
18- -- * Safe conversion functions
18+ -- * Pointer conversion functions
1919 , fromPtr
2020 , fromPtr0
2121 , useAsPtr
@@ -25,13 +25,12 @@ module Data.Text.Foreign
2525 , withCString
2626 , peekCStringLen
2727 , withCStringLen
28- -- * Unsafe conversion code
29- , lengthWord8
30- , unsafeCopyToPtr
3128 -- * Low-level manipulation
3229 -- $lowlevel
3330 , dropWord8
3431 , takeWord8
32+ , lengthWord8
33+ , unsafeCopyToPtr
3534 ) where
3635
3736import Control.Monad.ST.Unsafe (unsafeSTToIO )
@@ -69,6 +68,10 @@ newtype I8 = I8 Int
6968
7069-- | /O(n)/ Create a new 'Text' from a 'Ptr' 'Word8' by copying the
7170-- contents of the array.
71+ --
72+ -- __This function is unsafe.__ The source array must contain a valid
73+ -- UTF-8 string of the given length. There are no guarantees about what
74+ -- happens otherwise.
7275fromPtr :: Ptr Word8 -- ^ source array
7376 -> I8 -- ^ length of source array (in 'Word8' units)
7477 -> IO Text
@@ -82,6 +85,9 @@ fromPtr ptr (I8 len) = unsafeSTToIO $ do
8285-- | /O(n)/ Create a new 'Text' from a 'Ptr' 'Word8' by copying the
8386-- contents of the NUL-terminated array.
8487--
88+ -- __This function is unsafe.__ The source array must contain a NULL-terminated
89+ -- valid UTF-8 string. There are no guarantees about what happens otherwise.
90+ --
8591-- @since 2.0.1
8692fromPtr0 :: Ptr Word8 -- ^ source array
8793 -> IO Text
You can’t perform that action at this time.
0 commit comments