diff --git a/Utility/OsPath.hs b/Utility/OsPath.hs index bd7baf85eb..9fa4e0f57e 100644 --- a/Utility/OsPath.hs +++ b/Utility/OsPath.hs @@ -24,6 +24,8 @@ import "os-string" System.OsString.Internal.Types import qualified Data.ByteString.Short as S #if defined(mingw32_HOST_OS) import GHC.IO (unsafePerformIO) +import System.OsString.Encoding.Internal (cWcharsToChars_UCS2) +import qualified System.OsString.Data.ByteString.Short.Word16 as BS16 #endif toOsPath :: RawFilePath -> OsPath @@ -38,7 +40,10 @@ toOsPath = OsString . PosixString . S.toShort fromOsPath :: OsPath -> RawFilePath #if defined(mingw32_HOST_OS) -fromOsPath = S.fromShort . getWindowsString . getOsString +-- On Windows, OsString contains a ShortByteString that is +-- utf-16 encoded. So have to convert the input from that. +-- This is relatively expensive. +fromOsPath = toRawFilePath . cWcharsToChars_UCS2 . BS16.unpack . getWindowsString #else fromOsPath = S.fromShort . getPosixString . getOsString #endif