From: "Rüdiger Bahns" Date: 2009-09-02T19:35:10+09:00 Subject: Re: how to convert string to binary and back in Ruby 1.9? Joe schrieb: > I'm using Ruby 1.9.1-p243 on Mac OS X 10.5.8. > > I have this UTF-8 string that I want to turn into binary, and then > from binary into ISO-8859-1. What means to "turn a string from binary to ISO-8859-1"? >>>> 'помоник'.encode('utf_8').decode('latin_1') > 'помоник' What Python does here is it encodes the string (from its internal unicode format) to an utf-8 binary-string and then converts it again into its internal unicode-format (interpreting it as latin-1 string). Finally it puts it out to the console which means that it converts it again (to probably utf-8) for the Mac Os Terminal. This is an important point you should keep in mind. So this is quiet similar to what ruby does except that ruby makes no conversion to an general internal format and no special conversion for the terminal. If you would put the results out to a file you would have the same result. Regards, R.