[#47319] Translating MRI Guides! — Zachary Scott <zachary@...>
Hello Hashimoto-san!
5 messages
2013/05/03
[#47340] [ruby-trunk - Bug #8401][Open] BigDecimal.new("2").power(1e20) is zero. — "akr (Akira Tanaka)" <akr@...>
4 messages
2013/05/13
[#47341] LONG_LONG availability — Tanaka Akira <akr@...>
気がついてしまったのですが、Ruby 1.9.2 のころから
7 messages
2013/05/13
[#47363] -Lprefix/lib — Tanaka Akira <akr@...>
最近試しているクロスコンパイルな CI で、
5 messages
2013/05/22
[#47374] Re: [ruby-cvs:48158] xibbar:r40990 (trunk): fix a typo. — Zachary Scott <zachary@...>
Do you mean "modularized"?
3 messages
2013/05/30
[#47377] RubyKaigi 2013, 5/31(金)の'Ruby Comitter vs. the World'企画へのご協力のお願い — Kakutani Shintaro <shintaro@...>
かくたにです。RubyKaigi 2013 のほうから来ました。
5 messages
2013/05/30
[ruby-dev:47369] [ruby-trunk - Bug #8445][Open] IO.open and IO#set_enconding does not support :fallback option
From:
"pjmtdw (Haruhiro Yoshimoto)" <pjmtdw@...>
Date:
2013-05-24 13:03:02 UTC
List:
ruby-dev #47369
Issue #8445 has been reported by pjmtdw (Haruhiro Yoshimoto).
----------------------------------------
Bug #8445: IO.open and IO#set_enconding does not support :fallback option
https://bugs.ruby-lang.org/issues/8445
Author: pjmtdw (Haruhiro Yoshimoto)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: trunk(ruby 2.1.0dev)
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN
RubyDoc says that IO.open and IO#set_encoding supports optional argument defined in String#encode.
http://ruby-doc.org/core-2.0/IO.html#method-c-new-label-Options
In fact, :invalid, :undef and :replace works as expected.
However, :fallback option does not work neither for IO.open and IO#set_encoding.
Following is the example code which does not work.
f(x) is never called even if hoge.txt contains non convertible character.
File.open("./hoge.txt","r:Shift_JIS:utf-8", :fallback => lambda{|x|f(x)}){|f|
...
}
File.open("./hoge.txt"){|f|
f.set_encoding("Shift_JIS","utf-8",:fallback => lambda{|x|f(x)})
...
}
I Think this is because fill_cbuf() in io.c calls rb_econv_convert() from transcode.c directly.
On the other hand, fallback_func is called in transcode_loop(), which is called by str_encode().
Since transcode_loop() also calls rb_econv_convert(), I wrote a small patch which moves some codes from
transcode_loop() to rb_econv_convert() to fix the problem.
The attached file is the patch. Hope this helps.
--
http://bugs.ruby-lang.org/