Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
qoobaa-force_encoding
Advanced tools
= force_encoding
force_encoding is a Swiss Army knife for all the problems with Ruby 1.9 encodings.
== Description
Ruby 1.9.1 introduces really annoying mechanism - string encodings. Normally in 1.8 we didn't have to care about anything like this, now in 1.9 we have to use force_encoding method before any operations on the String object:
"some string".length #=> 11
We can't trust length method any more, because we don't know the encoding of string. To get the exact size (in bytes) of the string we have to write:
"some string".force_encoding(Encoding::ASCII_8BIT).length #=> 11
Using the force_encoding gem, we can just write:
"some string".feb.length #=> 11
Now we can compare the saved bytes in the source code (using force_encoding gem of course):
'"some string".force_encoding(Encoding::ASCII_8BIT).length'.feb.length #=> 57 '"some string".feb.length'.feb.length #=> 24
What a difference!
Because sometimes we don't want to modify the original string (there're still some people that don't use force_encoding before using a string!), the force_encoding gem has awesome methods dfeu and dfeb:
a = "asd".feu a.encoding #=> #Encoding:UTF-8 a.dfeb.length #=> 3 a.encoding #=> #Encoding:UTF-8
AWESOME! Think about the profit you can get from the library:
http://github.com/rails/rails/commit/e590508a9b7ab5cf99d7a7675a92a1257cb9f6f8
== Note on Patches/Pull Requests
== Copyright
Copyright (c) 2009 Jakub Kuźma. See LICENSE for details.
FAQs
Unknown package
We found that qoobaa-force_encoding demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.