filepath-2.0.0.3: Library for manipulating FilePaths in a cross platform way.
Safe HaskellNone
LanguageHaskell2010

System.OsString.Windows

Synopsis

Types

data WindowsString Source #

Commonly used windows string as UTF16 bytes.

Instances

Instances details
Eq WindowsString Source # 
Instance details

Defined in System.OsString.Internal.Types

Ord WindowsString Source # 
Instance details

Defined in System.OsString.Internal.Types

Read WindowsString Source #

Encodes as UTF-16LE.

Instance details

Defined in System.OsString.Internal.Types

Methods

readsPrec :: Int -> ReadS WindowsString

readList :: ReadS [WindowsString]

readPrec :: ReadPrec WindowsString

readListPrec :: ReadPrec [WindowsString]

Show WindowsString Source #

Decodes as UTF-16LE.

Instance details

Defined in System.OsString.Internal.Types

Methods

showsPrec :: Int -> WindowsString -> ShowS

show :: WindowsString -> String

showList :: [WindowsString] -> ShowS

IsString WindowsString Source # 
Instance details

Defined in System.OsString.Internal.Types

Methods

fromString :: String -> WindowsString

Generic WindowsString Source # 
Instance details

Defined in System.OsString.Internal.Types

Associated Types

type Rep WindowsString :: Type -> Type

Semigroup WindowsString Source # 
Instance details

Defined in System.OsString.Internal.Types

Monoid WindowsString Source # 
Instance details

Defined in System.OsString.Internal.Types

NFData WindowsString Source # 
Instance details

Defined in System.OsString.Internal.Types

Methods

rnf :: WindowsString -> ()

Lift WindowsString Source # 
Instance details

Defined in System.OsString.Internal.Types

Methods

lift :: WindowsString -> Q Exp

liftTyped :: WindowsString -> Q (TExp WindowsString)

type Rep WindowsString Source # 
Instance details

Defined in System.OsString.Internal.Types

type Rep WindowsString = D1 ('MetaData "WindowsString" "System.OsString.Internal.Types" "filepath-2.0.0.3-inplace" 'True) (C1 ('MetaCons "WS" 'PrefixI 'True) (S1 ('MetaSel ('Just "unWFP") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ShortByteString)))

data WindowsChar Source #

Instances

Instances details
Eq WindowsChar Source # 
Instance details

Defined in System.OsString.Internal.Types

Methods

(==) :: WindowsChar -> WindowsChar -> Bool

(/=) :: WindowsChar -> WindowsChar -> Bool

Ord WindowsChar Source # 
Instance details

Defined in System.OsString.Internal.Types

Show WindowsChar Source # 
Instance details

Defined in System.OsString.Internal.Types

Methods

showsPrec :: Int -> WindowsChar -> ShowS

show :: WindowsChar -> String

showList :: [WindowsChar] -> ShowS

Generic WindowsChar Source # 
Instance details

Defined in System.OsString.Internal.Types

Associated Types

type Rep WindowsChar :: Type -> Type

Methods

from :: WindowsChar -> Rep WindowsChar x

to :: Rep WindowsChar x -> WindowsChar

NFData WindowsChar Source # 
Instance details

Defined in System.OsString.Internal.Types

Methods

rnf :: WindowsChar -> ()

type Rep WindowsChar Source # 
Instance details

Defined in System.OsString.Internal.Types

type Rep WindowsChar = D1 ('MetaData "WindowsChar" "System.OsString.Internal.Types" "filepath-2.0.0.3-inplace" 'True) (C1 ('MetaCons "WW" 'PrefixI 'True) (S1 ('MetaSel ('Just "unWW") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word16)))

String construction

toPlatformStringUtf :: MonadThrow m => String -> m WindowsString Source #

Convert a String.

On windows this encodes as UTF16, which is a pretty good guess. On unix this encodes as UTF8, which is a good guess.

Throws a EncodingException if encoding fails.

toPlatformStringEnc :: TextEncoding -> String -> Either EncodingException WindowsString Source #

Like toPlatformStringUtf, except allows to provide an encoding.

toPlatformStringFS :: String -> IO WindowsString Source #

Like toPlatformStringUtf, except on unix this uses the current filesystem 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 (make sure to deeply evaluate the result to catch exceptions).

Throws a EncodingException if encoding fails.

bytesToPlatformString :: MonadThrow m => ByteString -> m WindowsString Source #

Constructs a platform string from a ByteString.

On windows, this ensures valid UCS-2LE, on unix it is passed unchecked. Note that this doesn't expand Word8 to Word16 on windows, so you may get invalid UTF-16.

Throws EncodingException on invalid UCS-2LE on windows (although unlikely).

pstr :: QuasiQuoter Source #

QuasiQuote a WindowsString. This accepts Unicode characters and encodes as UTF-16 on windows.

packPlatformString :: [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.

String deconstruction

fromPlatformStringUtf :: MonadThrow m => WindowsString -> m String Source #

Partial unicode friendly decoding.

On windows this decodes as UTF16-LE (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 EncodingException if decoding fails.

fromPlatformStringEnc :: TextEncoding -> WindowsString -> Either EncodingException String Source #

Like fromPlatformStringUtf, except allows to provide a text encoding.

The String is forced into memory to catch all exceptions.

fromPlatformStringFS :: WindowsString -> IO String Source #

Like fromPlatformStringUt, except on unix this uses the current filesystem locale for decoding instead of always UTF8. On windows, uses UTF-16LE.

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).

Throws EncodingException if decoding fails.

unpackPlatformString :: WindowsString -> [WindowsChar] Source #

Unpack a platform string to a list of platform words.

Word construction

unsafeFromChar :: Char -> WindowsChar Source #

Truncates to 2 octets.

Word deconstruction

toChar :: WindowsChar -> Char Source #

Converts back to a unicode codepoint (total).