> You can also manually allocate and poke data into raw memory using Foreign.Marshall.Alloc and Foreign.Storable, if you're feeling particularly masochistic ;) That's kind of what I did by the past (Aggregate Word8 into a single Word32), before I discovered Text for fast string handling.
I know about storable Vectors (and already use them, but not for text), but I would loose Haskell-side the functionnalities of Text (I'm handling textual data in the first place, not raw bytes). Text already provide all string handling/file reading functions. Or else you'd have a convenient way to convert Text into Vector? Le 21 mars 2012 12:35, James Cook <[email protected]> a écrit : > On Mar 21, 2012, at 4:35 AM, Yves Parès wrote: > > > Hello, > > > > I have to interact with a C++ library that accepts as string types > (putting c++ strings aside) pointers of wchar_t (CWString in Haskell) or > unsigned 32-bit int (Ptr Word32 for UTF-32 codepoints). > > The vector package has "storable" vectors, which are essentially raw C > arrays. It provides the function: > > Data.Vector.Storable.unsafeWith :: Storable a => Vector a -> (Ptr a > -> IO b) -> IO b > > This is probably the simplest way to do what you're describing. You can > also manually allocate and poke data into raw memory using > Foreign.Marshall.Alloc and Foreign.Storable, if you're feeling particularly > masochistic ;) > > -- James
_______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
