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?
On Aug 31, 12:47 pm, Intransition [email protected] 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?
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:
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs