Skip to content

Instantly share code, notes, and snippets.

@sunkencity
Created February 25, 2011 17:16
Show Gist options
  • Save sunkencity/844114 to your computer and use it in GitHub Desktop.
Save sunkencity/844114 to your computer and use it in GitHub Desktop.
#
# Short words in Rails locale files with åäö become binary!
# But the _why oneliner seems to work. The problem is probably elsewhere. Logging this for reference.
#
# http://stdlib.rubyonrails.org/libdoc/yaml/rdoc/classes/String.html
# File yaml/rubytypes.rb, line 145
# def is_binary_data?
# ( self.count( "^ -~", "^\r\n" ) / self.size > 0.3 || self.count( "\x00" ) > 0 ) unless empty?
# end
str = "Fråga"
puts str.count( "^ -~", "^\r\n" ) / str.size > 0.3
puts str.count( "\x00" ) > 0
puts "RnLDpWdh".unpack("m")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment