Forum: Ruby Encoding problem when i use unpack

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
oxman b. (Guest)
on 2009-03-27 19:45

I've a very strange problem when i use both unpack and encode, lets me
show you :
irb(main):034:0> "=E9".unpack("M*")[0]
=> "\xE9"
irb(main):035:0> "=E9".unpack("M*")[0].encode "UTF-8", "ISO-8859-1"
=> "\xE9"
irb(main):036:0> "\xE9".encode "UTF-8", "ISO-8859-1"
=> "é"
irb(main):037:0> "\xE9"
irb(main):038:0> "=E9".unpack("M*")[0]
"=E9".unpack("M*")[0].force_encoding("ASCII-8BIT").encode "UTF-8",
=> "\xE9"

Could you explain me how can i unpack then encode to UTF-8 ?
This topic is locked and can not be replied to.