Mastering Ruby strings and encodings
What this about?
As devs, you and I create tons of strings. Probably more than any other object on a day to day basis. How much do you really know about strings? How about encodings? How familiar are you with Unicode and UTF-8?
- By manipulating individual bytes you'll gain a better understanding of how encodings work. You'll also be better equipped to debug strings.
- You may have used Unicode and UTF-8 but do you know the difference? Understand what they are and how the most popular encoding in the world works.
- Not only learn about UTF-8 but know enough to work with any encoding you run across. Understand what code points are and how to use them.
- What are normalization forms? How do you work with them? And why are they important?
- Learn about the different methods for creating strings. Find out why you should use one over another. You'll see helpful methods like %q and *. Get the entire story about how best to use heredocs.
- Should your object provide an implicit string conversion or only explicit? Learn the difference between to_s and to_str.
- Become an expert in immutable strings via freezing them. Find out why immutable strings are useful and why it might become the new normal in Ruby 3.0.
- Go beyond common methods so that you know the best method to use at any given moment. You'll see how gsub is overused and how methods like deleteand tr can be better.
- Explore advanced solutions like using Encoding::Converter to fix invalid characters within a string.
I've been using Ruby for more than a decade. During that time, I've presented and written about Ruby including 13 articles in Ruby Weekly. I organize the Dallas Ruby Brigade and participate in open source. My most successful contribution is the ActiveInteraction gem with over 1.8k stars on GitHub.
While doing all of this I've gained a strong understanding of Ruby and I'm excited to share what I've learned.