Safe Haskell | None |
---|---|
Language | Haskell2010 |
Deprecated: Use System.OsString.Posix from os-string >= 2.0.0 package instead. This module will be removed in filepath >= 1.5.
Synopsis
- toChar :: PosixChar -> Char
- pack :: [PosixChar] -> PosixString
- unpack :: PosixString -> [PosixChar]
- unsafeFromChar :: Char -> PosixChar
- encodeUtf :: MonadThrow m => String -> m PosixString
- encodeWith :: TextEncoding -> String -> Either EncodingException PosixString
- encodeFS :: String -> IO PosixString
- decodeUtf :: MonadThrow m => PosixString -> m String
- decodeWith :: TextEncoding -> PosixString -> Either EncodingException String
- decodeFS :: PosixString -> IO String
- data PosixString
- data PosixChar
- pstr :: QuasiQuoter
- fromBytes :: MonadThrow m => ByteString -> m PosixString
Documentation
pack :: [PosixChar] -> PosixString Source #
Pack a list of platform words to a platform string.
Note that using this in conjunction with unsafeFromChar
to
convert from [Char]
to platform string is probably not what
you want, because it will truncate unicode code points.
unpack :: PosixString -> [PosixChar] Source #
Unpack a platform string to a list of platform words.
unsafeFromChar :: Char -> PosixChar Source #
Truncates to 1 octet.
encodeUtf :: MonadThrow m => String -> m PosixString Source #
Partial unicode friendly encoding.
This encodes as UTF8 (strictly), which is a good guess.
Throws an EncodingException
if encoding fails.
encodeWith :: TextEncoding -> String -> Either EncodingException PosixString Source #
Encode a String
with the specified encoding.
encodeFS :: String -> IO PosixString Source #
This mimics the behavior of the base library when doing filesystem operations, which uses shady PEP 383 style encoding (based on the current locale, but PEP 383 only works properly on UTF-8 encodings, so good luck).
Looking up the locale requires IO. If you're not worried about calls
to setFileSystemEncoding
, then unsafePerformIO
may be feasible (make sure
to deeply evaluate the result to catch exceptions).
decodeUtf :: MonadThrow m => PosixString -> m String Source #
Partial unicode friendly decoding.
This decodes as UTF8 (strictly), which is a good guess. Note that filenames on unix are encoding agnostic char arrays.
Throws a EncodingException
if decoding fails.
decodeWith :: TextEncoding -> PosixString -> Either EncodingException String Source #
Decode a PosixString
with the specified encoding.
The String is forced into memory to catch all exceptions.
decodeFS :: PosixString -> IO String Source #
This mimics the behavior of the base library when doing filesystem operations, which uses shady PEP 383 style encoding (based on the current locale, but PEP 383 only works properly on UTF-8 encodings, so good luck).
Looking up the locale requires IO. If you're not worried about calls
to setFileSystemEncoding
, then unsafePerformIO
may be feasible (make sure
to deeply evaluate the result to catch exceptions).
data PosixString Source #
Commonly used Posix string as uninterpreted char[]
array.
Instances
Instances
Generic PosixChar Source # | |||||
Defined in System.OsString.Internal.Types.Hidden
| |||||
Show PosixChar Source # | |||||
NFData PosixChar Source # | |||||
Defined in System.OsString.Internal.Types.Hidden | |||||
Eq PosixChar Source # | |||||
Ord PosixChar Source # | |||||
Defined in System.OsString.Internal.Types.Hidden | |||||
type Rep PosixChar Source # | |||||
Defined in System.OsString.Internal.Types.Hidden |
pstr :: QuasiQuoter Source #
QuasiQuote a PosixString
. This accepts Unicode characters
and encodes as UTF-8 on unix.
fromBytes :: MonadThrow m => ByteString -> m PosixString Source #
Constructs a platform string from a ByteString.
This is a no-op.