[commit: ghc] wip/remove-cabal-dep: Fix string conversions in ghc-pkg to be correct w.r.t. Unicode (85f8f20)

git at git.haskell.org git at git.haskell.org
Sun Aug 24 22:47:49 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/remove-cabal-dep
Link       : http://ghc.haskell.org/trac/ghc/changeset/85f8f20ea7e19a5fc3c6225431a6ccbb4f0f64e6/ghc

>---------------------------------------------------------------

commit 85f8f20ea7e19a5fc3c6225431a6ccbb4f0f64e6
Author: Duncan Coutts <duncan at well-typed.com>
Date:   Sun Aug 24 22:11:33 2014 +0100

    Fix string conversions in ghc-pkg to be correct w.r.t. Unicode
    
    Similar change to that on the ghc library side in the previous patch.
    The BinaryStringRep class has to use a ByteString in UTF8 encoding.


>---------------------------------------------------------------

85f8f20ea7e19a5fc3c6225431a6ccbb4f0f64e6
 utils/ghc-pkg/Main.hs | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs
index cedc048..ec23eb4 100644
--- a/utils/ghc-pkg/Main.hs
+++ b/utils/ghc-pkg/Main.hs
@@ -24,6 +24,7 @@ import Distribution.ModuleExport
 import Distribution.Package hiding (depends)
 import Distribution.Text
 import Distribution.Version
+import Distribution.Simple.Utils (fromUTF8, toUTF8)
 import System.FilePath as FilePath
 import qualified System.FilePath.Posix as FilePath.Posix
 import System.Process
@@ -1075,12 +1076,12 @@ convertPackageInfoToCacheFormat pkg =
     }
 
 instance GhcPkg.BinaryStringRep ModuleName where
-  fromStringRep = ModuleName.fromString . BS.unpack
-  toStringRep   = BS.pack . display
+  fromStringRep = ModuleName.fromString . fromUTF8 . BS.unpack
+  toStringRep   = BS.pack . toUTF8 . display
 
 instance GhcPkg.BinaryStringRep String where
-  fromStringRep = BS.unpack
-  toStringRep   = BS.pack
+  fromStringRep = fromUTF8 . BS.unpack
+  toStringRep   = BS.pack . toUTF8
 
 
 -- -----------------------------------------------------------------------------



More information about the ghc-commits mailing list