diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
 # Revision history for libBF-hs
 
+## 0.6.2 -- 2021-02-19
+
+* Fix a bug related to incorrect marshalling of String to C in
+  `setString` and `bfFromString`.
+
 ## 0.6.1 -- 2021-02-16
 
 * Fix a linker issue on Windows when loading via the GHC dynamic linker.
diff --git a/libBF.cabal b/libBF.cabal
--- a/libBF.cabal
+++ b/libBF.cabal
@@ -1,7 +1,7 @@
 cabal-version:       2.2
 
 name:                libBF
-version:             0.6.1
+version:             0.6.2
 synopsis:            A binding to the libBF library.
 description:         LibBF is a C library for working with arbitray precision
                      IEEE 754 floating point numbers.
diff --git a/src/LibBF/Mutable.hsc b/src/LibBF/Mutable.hsc
--- a/src/LibBF/Mutable.hsc
+++ b/src/LibBF/Mutable.hsc
@@ -75,8 +75,6 @@
 import Data.Hashable
 import Data.List(unfoldr)
 import Control.Monad(foldM,when)
-import Control.Exception(bracket)
-import GHC.IO.Encoding(getForeignEncoding,setForeignEncoding,char8)
 
 import Foreign.Storable
 
@@ -525,14 +523,11 @@
 setString radix (BFOpts prec flags) inStr =
   bf1    \bfPtr ->
   alloca \nextPtr ->
-  bracket (getForeignEncoding >>= \e -> setForeignEncoding char8 >> pure e)
-          setForeignEncoding
-  \_enc ->
-  withCStringLen inStr \(strPtr,len) ->
+  withCAString inStr \strPtr ->
   do stat <- bf_atof bfPtr strPtr nextPtr (fromIntegral radix) prec flags
      next <- peek nextPtr
      let consumed = next `minusPtr` strPtr
-         usedAll = len == consumed
+         usedAll = length inStr == consumed
      consumed `seq` usedAll `seq` pure (Status stat, consumed, usedAll)
 
 
