Created
May 21, 2013 14:54
-
-
Save cameronhotchkies/5620426 to your computer and use it in GitHub Desktop.
Why you shouldn't go back and forth on UTF-8 strings for binary data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run in a REPL | |
val bl : List[Byte] = List(-78,-5,-112,-31,127,-59,1,94,12,7,84,112,82,41,-95,50) | |
val ba = bl.toArray | |
val bs = new String(ba, "UTF-8") | |
bl.length | |
ba.length | |
bs.length | |
// Notice they aren't all equal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://stackoverflow.com/questions/5250324/byte-array-to-string-and-back-issues-with-127