| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
System.OsString.Windows
Synopsis
- data WindowsString
- data WindowsChar
- toPlatformString :: String -> WindowsString
- toPlatformStringIO :: String -> IO WindowsString
- bsToPlatformString :: MonadThrow m => ByteString -> m WindowsString
- pstr :: QuasiQuoter
- packPlatformString :: [WindowsChar] -> WindowsString
- fromPlatformString :: MonadThrow m => WindowsString -> m String
- fromPlatformStringIO :: WindowsString -> IO String
- unpackPlatformString :: WindowsString -> [WindowsChar]
- unsafeFromChar :: Char -> WindowsChar
- toChar :: WindowsChar -> Char
Types
data WindowsString Source #
Commonly used windows string as UTF16 bytes.
Instances
data WindowsChar Source #
Instances
String construction
toPlatformString :: String -> WindowsString 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.
toPlatformStringIO :: String -> IO WindowsString Source #
Like toPlatformString, 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.
bsToPlatformString :: MonadThrow m => ByteString -> m WindowsString Source #
Constructs an platform string from a ByteString.
On windows, this ensures valid UTF16, on unix it is passed unchanged/unchecked.
Throws UnicodeException on invalid UTF16 on windows.
pstr :: QuasiQuoter Source #
QuasiQuote a WindowsString. This accepts Unicode characters
and encodes as UTF-16 on windows.
String deconstruction
fromPlatformString :: MonadThrow m => WindowsString -> 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.
fromPlatformStringIO :: WindowsString -> IO String Source #
Like fromPlatformString, 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.
Word construction
unsafeFromChar :: Char -> WindowsChar Source #
Truncates to 2 octets.
Word deconstruction
toChar :: WindowsChar -> Char Source #
Converts back to a unicode codepoint (total).