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 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:
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 = 'U\*' else unpack\_rule = 'C\*' end$KCODE is no long effective, so what to do for 1.9?