| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
System.OsString.Internal
Synopsis
- toOsString :: String -> OsString
- toOsStringIO :: String -> IO OsString
- fromOsString :: MonadThrow m => OsString -> m String
- fromOsStringEnc :: OsString -> TextEncoding -> Either UnicodeException String
- fromOsStringIO :: OsString -> IO String
- bsToOsString :: MonadThrow m => ByteString -> m OsString
- qq :: (ByteString -> Q Exp) -> QuasiQuoter
- mkOsString :: ByteString -> Q Exp
- osstr :: QuasiQuoter
- unpackOsString :: OsString -> [OsChar]
- packOsString :: [OsChar] -> OsString
- unsafeFromChar :: Char -> OsChar
- toChar :: OsChar -> Char
Documentation
toOsString :: String -> OsString Source #
Total Unicode-friendly encoding.
On windows this encodes as UTF16, which is expected. On unix this encodes as UTF8, which is a good guess.
toOsStringIO :: String -> IO OsString Source #
Like toOsString, except on unix this uses the current
locale for encoding instead of always UTF8.
Looking up the locale requires IO. If you're not worried about calls
to setFileSystemEncoding, then unsafePerformIO may be feasible.
fromOsString :: MonadThrow m => OsString -> m String Source #
Partial unicode friendly decoding.
On windows this decodes as UTF16 (which is the expected filename encoding). On unix this decodes as UTF8 (which is a good guess). Note that filenames on unix are encoding agnostic char arrays.
Throws a UnicodeException if decoding fails.
fromOsStringEnc :: OsString -> TextEncoding -> Either UnicodeException String Source #
Like fromOsString, except on unix this uses the provided
TextEncoding for decoding.
On windows, the TextEncoding parameter is ignored.
fromOsStringIO :: OsString -> IO String Source #
Like fromOsString, except on unix this uses the current
locale for decoding instead of always UTF8.
Looking up the locale requires IO. If you're not worried about calls
to setFileSystemEncoding, then unsafePerformIO may be feasible.
Throws UnicodeException if decoding fails.
bsToOsString :: MonadThrow m => ByteString -> m OsString Source #
Constructs an OsString from a ByteString.
On windows, this ensures valid UTF16, on unix it is passed unchanged/unchecked.
Throws UnicodeException on invalid UTF16 on windows.
qq :: (ByteString -> Q Exp) -> QuasiQuoter Source #
mkOsString :: ByteString -> Q Exp Source #
osstr :: QuasiQuoter Source #
QuasiQuote an OsString. This accepts Unicode characters
and encodes as UTF-8 on unix and UTF-16 on windows.
unpackOsString :: OsString -> [OsChar] Source #
packOsString :: [OsChar] -> OsString Source #
unsafeFromChar :: Char -> OsChar Source #
Truncates on unix to 1 and on Windows to 2 octets.