Ruby/Rails String to Unicode conversion...

Hello everyone,
I am working on my first professional programming project, and so far
it's been pretty good, but I have a small problem. The project is
being developed in Ruby on Rails, but involves dealing with a legacy
database full of old usernames/passwords which are still being used.
The passwords are encrypted via some hashing method, but for
internationalization purposes, they are first converted to Unicode
strings before being hashed. This is the part that is not working -
the hashed String password and hashed Unicode password are totally
different. I've been thinking about it and just can't figure how to
turn a standard ::String into a Unicode string. Any help or insights
would really really really be appreciated!

"Unicode" is not a format. Rails strings are UTF-8, which is a particular unicode encoding. You need to know which unicode encoding your target strings are in.

Once you know that, you need to look at Iconv. It's part of the Ruby standard library set.

Pete Yandell

You can use Iconv. perhaps those two methods I use might help you ?
you can change the encoding to get what you want, eg. unicode string
as UTF-16

    def to_iso8859_1(value)
      Iconv.iconv('ISO-8859-1','UTF-8', value).join

    def to_utf_8(value)
      Iconv.iconv('UTF-8','ISO-8859-1', value).join
    end schrieb: