|
Data.Text.Foreign | Portability | GHC | Stability | experimental | Maintainer | bos@serpentine.com, rtomharper@googlemail.com,
duncan@haskell.org |
|
|
|
|
|
Description |
Support for using Text data with native code via the Haskell
foreign function interface.
|
|
Synopsis |
|
|
|
|
Interoperability with native code
|
|
The Text type is implemented using arrays that are not guaranteed
to have a fixed address in the Haskell heap. All communication with
native code must thus occur by copying data back and forth.
The Text type's internal representation is UTF-16, using the
platform's native endianness. This makes copied data suitable for
use with native libraries that use a similar representation, such
as ICU. To interoperate with native libraries that use different
internal representations, such as UTF-8 or UTF-32, consider using
the functions in the Data.Text.Encoding module.
|
|
Safe conversion functions
|
|
|
|
|
|
O(n) Perform an action on a temporary, mutable copy of a
Text. The copy is freed as soon as the action returns.
|
|
Unsafe conversion code
|
|
|
O(1) Return the length of a Text in units of Word16. This
is useful for sizing a target array appropriately before using
unsafeCopyToPtr.
|
|
|
O(n) Copy a Text to an array. The array is assumed to be big
enough to hold the contents of the entire Text.
|
|
Low-level manipulation
|
|
Foreign functions that use UTF-16 internally may return indices in
units of Word16 instead of characters. These functions may
safely be used with such indices, as they will adjust offsets if
necessary to preserve the validity of a Unicode string.
|
|
|
O(1) Return the suffix of the Text, with n Word16 units
dropped from its beginning.
If n would cause the Text to begin inside a surrogate pair, the
beginning of the suffix will be advanced by one additional Word16
unit to maintain its validity.
|
|
|
O(1) Return the prefix of the Text of n Word16 units in
length.
If n would cause the Text to end inside a surrogate pair, the
end of the prefix will be advanced by one additional Word16 unit
to maintain its validity.
|
|
Produced by Haddock version 2.6.0 |