Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentError: ASCII incompatible encoding needs binmode when using NKF #4575

Open
zhangch-fnst opened this issue Apr 26, 2017 · 2 comments
Open

Comments

@zhangch-fnst
Copy link

zhangch-fnst commented Apr 26, 2017

Here is my code:

external_encoding = Encoding::SJIS
html = open(file, "r:#{external_encoding}", invalid: :replace, undef: :replace ) do |f|
require "nkf"
external_encoding = NKF.guess(f.read)
f.reopen(file, "r:#{external_encoding}")
f.read
end

Exception

My file is a Japanese file.So NKF.guess's value is ISO-2022-JP.
But Exception throws in f.reopen :

ArgumentError:ASCII incompatible encoding needs binmode when using NKF

Environment

jruby-9.1.8.0
Windows7_X64

@zhangch-fnst
Copy link
Author

I di that:
f.reopen(file, "rb:#{external_encoding}")
It gone to be OK!

@kares
Copy link
Member

kares commented May 29, 2017

@zhangch-fnst still an issue than? if so could we get the file or a reproducable piece for NKF.guess(...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants