Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Null-terminate Text bytestrings #33

Merged
merged 1 commit into from

2 participants

@lukexi
Collaborator

This is to close #31 — 

ByteString.unpack $ encodeUtf8 txt

doesn't null-terminate its arrays, which [NSString stringWithUTF8String:] expects.

Hurray!

@jspahrsummers

Thanks!

@jspahrsummers jspahrsummers merged commit 15ae2ca into jspahrsummers:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 2, 2012
  1. @lukexi
This page is out of date. Refresh to see the latest.
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)
Something went wrong with that request. Please try again.