Ok, so no $KCODE --a chance to learn a little about Encodings

I am working on some 1.8 to 1.9 compatibility. I have a bit of code:

    if $KCODE =~ /^U/i
      unpack_rule = 'U*'
    else
      unpack_rule = 'C*'
    end

$KCODE is no long effective, so what to do for 1.9?

I think I have figured it out. Given two strings to compare we can do:

    if str2.encoding != str1.encoding
      str2 = str2.encode(str1.encoding.name)
    end

    s = str1.codepoints.to_a
    t = str2.codepoints.to_a

Where #codepoints does the same as old str.unpack(unpack_rule).

This page was very helpful:

  Gray Soft / Not Found

···

On Aug 31, 12:47 pm, Intransition <transf...@gmail.com> wrote:

I am working on some 1.8 to 1.9 compatibility. I have a bit of code:

if $KCODE =\~ /^U/i
  unpack\_rule = &#39;U\*&#39;
else
  unpack\_rule = &#39;C\*&#39;
end

$KCODE is no long effective, so what to do for 1.9?