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 :: WindowsChar -> Char
- pack :: [WindowsChar] -> WindowsString
- unpack :: WindowsString -> [WindowsChar]
- unsafeFromChar :: Char -> WindowsChar
- encodeUtf :: MonadThrow m => String -> m WindowsString
- encodeWith :: TextEncoding -> String -> Either EncodingException WindowsString
- encodeFS :: String -> IO WindowsString
- decodeUtf :: MonadThrow m => WindowsString -> m String
- decodeWith :: TextEncoding -> WindowsString -> Either EncodingException String
- decodeFS :: WindowsString -> IO String
- pstr :: QuasiQuoter
- data WindowsString
- data WindowsChar
- fromBytes :: MonadThrow m => ByteString -> m WindowsString
Documentation
toChar :: WindowsChar -> Char Source #
Converts back to a unicode codepoint (total).
pack :: [WindowsChar] -> WindowsString 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 :: WindowsString -> [WindowsChar] Source #
Unpack a platform string to a list of platform words.
unsafeFromChar :: Char -> WindowsChar Source #
Truncates to 2 octets.
encodeUtf :: MonadThrow m => String -> m WindowsString Source #
Partial unicode friendly encoding.
This encodes as UTF16-LE (strictly), which is a pretty good guess.
Throws an EncodingException
if encoding fails.
encodeWith :: TextEncoding -> String -> Either EncodingException WindowsString Source #
Encode a String
with the specified encoding.
encodeFS :: String -> IO WindowsString Source #
This mimics the behavior of the base library when doing filesystem operations, which does permissive UTF-16 encoding, where coding errors generate Chars in the surrogate range.
The reason this is in IO is because it unifies with the Posix counterpart,
which does require IO. This is safe to unsafePerformIO
/unsafeDupablePerformIO
.
decodeUtf :: MonadThrow m => WindowsString -> m String Source #
Partial unicode friendly decoding.
This decodes as UTF16-LE (strictly), which is a pretty good.
Throws a EncodingException
if decoding fails.
decodeWith :: TextEncoding -> WindowsString -> Either EncodingException String Source #
Decode a WindowsString
with the specified encoding.
The String is forced into memory to catch all exceptions.
decodeFS :: WindowsString -> IO String Source #
Like decodeUtf
, except this mimics the behavior of the base library when doing filesystem
operations, which does permissive UTF-16 encoding, where coding errors generate
Chars in the surrogate range.
The reason this is in IO is because it unifies with the Posix counterpart,
which does require IO. unsafePerformIO
/unsafeDupablePerformIO
are safe, however.
pstr :: QuasiQuoter Source #
QuasiQuote a WindowsString
. This accepts Unicode characters
and encodes as UTF-16LE on windows.
data WindowsString Source #
Commonly used windows string as wide character bytes.
Instances
data WindowsChar Source #
Instances
Generic WindowsChar Source # | |||||
Defined in System.OsString.Internal.Types.Hidden
from :: WindowsChar -> Rep WindowsChar x Source # to :: Rep WindowsChar x -> WindowsChar Source # | |||||
Show WindowsChar Source # | |||||
Defined in System.OsString.Internal.Types.Hidden | |||||
NFData WindowsChar Source # | |||||
Defined in System.OsString.Internal.Types.Hidden rnf :: WindowsChar -> () Source # | |||||
Eq WindowsChar Source # | |||||
Defined in System.OsString.Internal.Types.Hidden (==) :: WindowsChar -> WindowsChar -> Bool # (/=) :: WindowsChar -> WindowsChar -> Bool # | |||||
Ord WindowsChar Source # | |||||
Defined in System.OsString.Internal.Types.Hidden compare :: WindowsChar -> WindowsChar -> Ordering # (<) :: WindowsChar -> WindowsChar -> Bool # (<=) :: WindowsChar -> WindowsChar -> Bool # (>) :: WindowsChar -> WindowsChar -> Bool # (>=) :: WindowsChar -> WindowsChar -> Bool # max :: WindowsChar -> WindowsChar -> WindowsChar # min :: WindowsChar -> WindowsChar -> WindowsChar # | |||||
type Rep WindowsChar Source # | |||||
Defined in System.OsString.Internal.Types.Hidden type Rep WindowsChar = D1 ('MetaData "WindowsChar" "System.OsString.Internal.Types.Hidden" "filepath-1.4.200.1-2a10" 'True) (C1 ('MetaCons "WindowsChar" 'PrefixI 'True) (S1 ('MetaSel ('Just "getWindowsChar") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word16))) |
fromBytes :: MonadThrow m => ByteString -> m WindowsString Source #
Constructs a platform string from a ByteString.
This ensures valid UCS-2LE. Note that this doesn't expand Word8 to Word16 on windows, so you may get invalid UTF-16.
Throws EncodingException
on invalid UCS-2LE (although unlikely).