From: Joe Date: 2009-09-02T08:55:06+09:00 Subject: Re: how to convert string to binary and back in Ruby 1.9? On Sep 1, 4:18 pm, Iñaki Baz Castillo wrote: > El Miércoles, 2 de Septiembre de 2009, Joe escribió: > In the other way, #encode does change the encoding, and it fails if the > conversion is not possible. > > -- > Iñaki Baz Castillo OK, so String#force_encoding just changes the encoding, but does not alter the string. But how does it decide to print as the same sequence of Cyrillic characters, when it thinks its encoding is ISO-8859-1? How does ruby1.9 decide what characters to display when printing a String? Surely it must adhere to the encoding of that String? Is ruby storing the ISO-8859-1 encoded string as a sequence of unicode characters, or what? This seems crazy to me. OK, so maybe String#force_encoding is crazy and broken or just won't be able to do what I want. Your suggestion was that String#encode is the method for changing the string. Of course I tried that one, and it errors because there is no Cyrillic alphabet in ISO-8859-1. Is there really no way to go from bytes to string? That's all I want!