Skip to content

Instantly share code, notes, and snippets.

@cameronhotchkies
Created May 21, 2013 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cameronhotchkies/5620426 to your computer and use it in GitHub Desktop.
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
// 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