Created
June 30, 2013 18:04
-
-
Save dankogai/5896195 to your computer and use it in GitHub Desktop.
bsfilter bsfilter-1.0.18.ruby1.9.rc5 workaround that dies with "ArgumentError: invalid byte sequence"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- bsfilter.1.0.18rc5 Sun Mar 10 03:03:03 2013 | |
+++ bsfilter Mon Jul 1 02:52:54 2013 | |
@@ -933,24 +933,27 @@ | |
if (str.force_encoding('ASCII-8BIT') =~ reg_gb18030_possible) | |
gb18030_possible = true | |
end | |
- | |
- if (str.encode('UTF-8', 'UTF-8') =~ reg_utf8) | |
- @options["message-fh"].printf("lang ja utf8\n") if (@options["debug"]) | |
- return ["ja", "utf8"] | |
- elsif (str.force_encoding('ASCII-8BIT') =~ reg_jis) | |
- @options["message-fh"].printf("lang ja jis\n") if (@options["debug"]) | |
- return ["ja", "jis"] | |
- elsif (str.encode('SHIFT_JIS', 'SHIFT_JIS') =~ reg_sjis) | |
- @options["message-fh"].printf("lang ja sjis\n") if (@options["debug"]) | |
- return ["ja", "sjis"] | |
- elsif (str.encode('EUC-JP', 'EUC-JP') =~ reg_euc) | |
- if (gb18030_possible) | |
- @options["message-fh"].printf("lang ja gb18030\n") if (@options["debug"]) | |
- return ["ja", "gb18030"] | |
- else | |
- @options["message-fh"].printf("lang ja euc\n") if (@options["debug"]) | |
- return ["ja", "euc"] | |
+ begin | |
+ if (str.encode('UTF-8', 'UTF-8') =~ reg_utf8) | |
+ @options["message-fh"].printf("lang ja utf8\n") if (@options["debug"]) | |
+ return ["ja", "utf8"] | |
+ elsif (str.force_encoding('ASCII-8BIT') =~ reg_jis) | |
+ @options["message-fh"].printf("lang ja jis\n") if (@options["debug"]) | |
+ return ["ja", "jis"] | |
+ elsif (str.encode('SHIFT_JIS', 'SHIFT_JIS') =~ reg_sjis) | |
+ @options["message-fh"].printf("lang ja sjis\n") if (@options["debug"]) | |
+ return ["ja", "sjis"] | |
+ elsif (str.encode('EUC-JP', 'EUC-JP') =~ reg_euc) | |
+ if (gb18030_possible) | |
+ @options["message-fh"].printf("lang ja gb18030\n") if (@options["debug"]) | |
+ return ["ja", "gb18030"] | |
+ else | |
+ @options["message-fh"].printf("lang ja euc\n") if (@options["debug"]) | |
+ return ["ja", "euc"] | |
+ end | |
end | |
+ rescue => err | |
+ p err | |
end | |
end | |
return [nil, nil] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment