lib/i18n_screwdriver.rb in i18n_screwdriver-2.0.0 vs lib/i18n_screwdriver.rb in i18n_screwdriver-2.0.1
- old
+ new
@@ -38,7 +38,38 @@
hash.each do |k, v|
result[k.encode('UTF-8')] = (v || "").encode('UTF-8')
end
end
end
+
+ def self.unescape_string(string)
+ "".tap do |result|
+ in_backslash = false
+ string.each_char do |char|
+ if in_backslash
+ case char
+ when 'r'
+ result << "\r"
+ when 'n'
+ result << "\n"
+ when 't'
+ result << "\t"
+ when '\\'
+ result << '\\'
+ else
+ result << '\\'
+ result << char
+ end
+ in_backslash = false
+ else
+ case char
+ when '\\'
+ in_backslash = true
+ else
+ result << char
+ end
+ end
+ end
+ end
+ end
end