Encoding Problems in Ruby

String encoding is something that we don't really think until we see Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT Or when users complains about missing special characters like "’" (apostrophe copied from Microsoft Word) or when "菜医生" becomes "иЏњеЊ»з”џ". Before we go into encoding problems, lets understand what encoding is. A string can be considered as an array of bytes: irb(main):001:0> "world".bytes => [119, 111, 114, 108, 100] Here 119 means w, 111 means o and so on. This relationship between bytes and characters is