Skip to content
Browse files

Null-terminate byte arrays coming from unpacked Text

  • Loading branch information...
1 parent e55cff4 commit 44f725cac069f22625b312ab3fa31ff5dc088382 @lukexi lukexi committed
Showing with 1 addition and 1 deletion.
  1. +1 −1 ObjectiveHaskell/NSString.hs
View
2 ObjectiveHaskell/NSString.hs
@@ -32,7 +32,7 @@ fromNSString obj = do
-- | Converts a 'Text' value into an immutable @NSString@.
toNSString :: Text -> IO Id
toNSString txt =
- let arr = ByteString.unpack $ encodeUtf8 txt
+ let arr = (ByteString.unpack $ encodeUtf8 txt) ++ [0]
in withArray arr $ \ptr ->
getClass "NSString" >>= stringWithUtf8String (castPtr ptr)

0 comments on commit 44f725c

Please sign in to comment.
Something went wrong with that request. Please try again.