It think you might not need to go via CString to get to the browser, given that the browser side doesn't care about NUL termination either. I think you could use Data.ByteString.Internal to grab the ForeignPtr/length out of the BS constructor directly.