Skip to content

Instantly share code, notes, and snippets.

@hirataya
Created December 28, 2011 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hirataya/1528729 to your computer and use it in GitHub Desktop.
Save hirataya/1528729 to your computer and use it in GitHub Desktop.
Cinch quick fix
diff --git a/lib/cinch/utilities/encoding.rb b/lib/cinch/utilities/encoding.rb
index 2a248e2..a4d1bcb 100644
--- a/lib/cinch/utilities/encoding.rb
+++ b/lib/cinch/utilities/encoding.rb
@@ -17,7 +17,7 @@ module Cinch
string.force_encoding("CP1252").encode!("UTF-8", {:invalid => :replace, :undef => :replace})
end
else
- string.force_encoding(encoding).encode!({:invalid => :replace, :undef => :replace})
+ string.force_encoding(encoding).encode!("UTF-8", {:invalid => :replace, :undef => :replace})
string = string.chars.select { |c| c.valid_encoding? }.join
end
@@ -44,7 +44,7 @@ module Cinch
rescue ::Encoding::UndefinedConversionError
end
else
- string.encode!(encoding, {:invalid => :replace, :undef => :replace})
+ string.encode!(encoding, {:invalid => :replace, :undef => :replace}).force_encoding("binary")
end
return string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment