Skip to content

Instantly share code, notes, and snippets.

@teknofire
Last active November 20, 2018 21:42
Show Gist options
  • Save teknofire/4dfac249b9e979af7aac6988a3178d9a to your computer and use it in GitHub Desktop.
Save teknofire/4dfac249b9e979af7aac6988a3178d9a to your computer and use it in GitHub Desktop.
a = "\x91" # Windows-1252 hex code for curly quote
puts a
puts a.valid_encoding?
puts a.force_encoding('Windows-1252')
puts a.force_encoding('Windows-1252').encode('UTF-8')
irb(main):034:0> a = "\x91" # Windows-1252 hex code for curly quote
=> "\x91"
irb(main):035:0> puts a
=> nil
irb(main):036:0> puts a.valid_encoding?
false
=> nil
irb(main):037:0> puts a.force_encoding('Windows-1252')
=> nil
irb(main):038:0> puts a.force_encoding('Windows-1252').encode('UTF-8')
=> nil
irb(main):039:0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment