4 ms·
All You Need to Know About Encodings and Ruby 1.9
- 1053r 16y agoJudging by the comments echoing throughout the blog-sphere, it seems like encodings (and a reluctance to move to Rails 3 because it is new) is the main thing preventing people from moving to Ruby 1.9. But I can't wait for folks to move over so we can finally put to rest all the complaints about ruby being so slow. http://www.rubychan.de/share/yarv_speedups.html http://www.rubychan.de/share/yarv_speedups.html (Link contains comparison of speed of ruby 1.8.6 to 1.9.2).
- cageface 16y agoThis article summarizes the problems posed by encoding issues and the approach Ruby takes to solving them better than any of the many other articles on the subject I've read. Worth a read, particularly for anybody planning on deploying Rails 3.0/Ruby 1.9 apps.
- jrockway 16y agoI think we can simplify even further. Computers communicate with bytes. Sockets stream bytes. Files contain bytes. Your database stores bytes. The problem is that humans communicate with characters, not bytes. And so you need a function to convert bytes to characters and characters to bytes, so that human conversations can happen on top of computer conversations. Once you understand "why" you need to encode/decode, then everything else is simple.
- nex3 16y agoThis is a great summary of why you get encoding errors in Ruby 1.9, and why #force_encoding is not the catch-all solution. I've lost count of how many times I've had people request that I run #force_encoding on all strings passed to Haml templates.