Skip to content

Instantly share code, notes, and snippets.

@kamarcum
Created October 28, 2012 16:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamarcum/3969065 to your computer and use it in GitHub Desktop.
Save kamarcum/3969065 to your computer and use it in GitHub Desktop.
Generating non-UTF-8 strings in ruby for testing
# It's sort of difficult to make a non-UTF-8 string in
# ruby that contains characters that aren't in UTF-8.
# Here's how I did it.
# 0x89 isn't allowed in UTF-8
bad_chars = [0x89].pack("c*").force_encoding("ISO-8859-1")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment