ruby binary string compare -
i want clarify understanding of string comparison in ruby.
how ruby compare binary strings?
does (a) split strings on utf-8 characters, compare strings based on length of binary string in utf-8 characters , values of utf-8 characters, or (b) compare strings on byte level?
it depends on version of ruby you're using
in ruby 1.8, strings collection of bytes.
in ruby 1.9, strings collection of encoded data.
string comparisons in ruby 1.9 done on byte level, other operations regex matches not. best normalize string objects same encoding before comparing them.
Comments
Post a Comment