Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- toOsPathUtf :: MonadThrow m => String -> m OsPath
- toOsPathEnc :: TextEncoding -> TextEncoding -> String -> Either EncodingException OsPath
- toOsPathFS :: String -> IO OsPath
- fromOsPathUtf :: MonadThrow m => OsPath -> m String
- fromOsPathEnc :: TextEncoding -> TextEncoding -> OsPath -> Either EncodingException String
- fromOsPathFS :: OsPath -> IO String
- bytesToAFP :: MonadThrow m => ByteString -> m OsPath
- mkOsPath :: ByteString -> Q Exp
- afp :: QuasiQuoter
- unpackAFP :: OsPath -> [OsChar]
- packAFP :: [OsChar] -> OsPath
Documentation
toOsPathUtf :: MonadThrow m => String -> m OsPath Source #
Partial unicode friendly encoding.
On windows this encodes as UTF16-LE (strictly), which is a pretty good guess. On unix this encodes as UTF8 (strictly), which is a good guess.
Throws a EncodingException
if encoding fails.
:: TextEncoding | unix text encoding |
-> TextEncoding | windows text encoding |
-> String | |
-> Either EncodingException OsPath |
Like toOsPathUtf
, except allows to provide encodings.
toOsPathFS :: String -> IO OsPath Source #
Like toOsPathUtf
, except this mimics the behavior of the base library when doing filesystem
operations, which is:
- on unix, uses shady PEP 383 style encoding (based on the current locale, but PEP 383 only works properly on UTF-8 encodings, so good luck)
- on windows does permissive UTF-16 encoding, where coding errors generate Chars in the surrogate range
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).
fromOsPathUtf :: MonadThrow m => OsPath -> m String Source #
Partial unicode friendly decoding.
On windows this decodes as UTF16-LE (strictly), which is a pretty good guess. On unix this decodes as UTF8 (strictly), which is a good guess.
Throws a EncodingException
if decoding fails.
:: TextEncoding | unix text encoding |
-> TextEncoding | windows text encoding |
-> OsPath | |
-> Either EncodingException String |
Like fromOsPathUtf
, except allows to provide encodings.
fromOsPathFS :: OsPath -> IO String Source #
Like fromOsPathUtf
, except this mimics the behavior of the base library when doing filesystem
operations, which is:
- on unix, uses shady PEP 383 style encoding (based on the current locale, but PEP 383 only works properly on UTF-8 encodings, so good luck)
- on windows does permissive UTF-16 encoding, where coding errors generate Chars in the surrogate range
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).
bytesToAFP :: MonadThrow m => ByteString -> m OsPath Source #
Constructs an OsPath
from a ByteString.
On windows, this ensures valid UCS-2LE, on unix it is passed unchanged/unchecked.
Throws EncodingException
on invalid UCS-2LE on windows (although unlikely).
mkOsPath :: ByteString -> Q Exp Source #
QuasiQuote an OsPath
. This accepts Unicode characters
and encodes as UTF-8 on unix and UTF-16 on windows. Runs filepathIsValid
on the input.