aboutsummaryrefslogtreecommitdiffstats
path: root/lib/normalize_string.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/normalize_string.rb')
-rw-r--r--lib/normalize_string.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/normalize_string.rb b/lib/normalize_string.rb
index 8b54c080c..69853fd6e 100644
--- a/lib/normalize_string.rb
+++ b/lib/normalize_string.rb
@@ -73,13 +73,18 @@ def convert_string_to_utf8_or_binary(s, suggested_character_encoding=nil)
result
end
+class StringConversionResult < Struct.new(:string, :scrubbed)
+ alias_method :scrubbed?, :scrubbed
+end
+
def convert_string_to_utf8(s, suggested_character_encoding=nil)
begin
result = normalize_string_to_utf8 s, suggested_character_encoding
+ StringConversionResult.new(result, false)
rescue EncodingNormalizationError
result = scrub(s)
+ StringConversionResult.new(result, true)
end
- result
end
def scrub(string)