lib/rmega/utils.rb in rmega-0.2.6 vs lib/rmega/utils.rb in rmega-0.2.7

- old
+ new

@@ -38,7 +38,14 @@ n = i < 4 ? 0 : 4 ary[i] = bytes[i+n] ^ bytes[i+n+4] ary end.map(&:chr).join end + + def utf8(s) + str = s.dup + str.force_encoding("UTF-8") + str.encode!("UTF-8", invalid: :replace, replace: "-") + return str + end end end