[#62904] [ruby-trunk - Feature #9894] [Open] [RFC] README.EXT: document rb_gc_register_mark_object — normalperson@...
Issue #9894 has been reported by Eric Wong.
3 messages
2014/06/02
[#63321] [ANN] ElixirConf 2014 - Don't Miss Jos辿 Valim and Dave Thomas — Jim Freeze <jimfreeze@...>
Just a few more weeks until ElixirConf 2014!
6 messages
2014/06/24
[ruby-core:63035] [ruby-trunk - Bug #9766] [Closed] Add force_encoding option to csv
From:
nobu@...
Date:
2014-06-10 01:57:18 UTC
List:
ruby-core #63035
Issue #9766 has been updated by Nobuyoshi Nakada.
Status changed from Assigned to Closed
% Done changed from 0 to 100
Applied in changeset r46391.
----------
csv.rb: honor encoding option
* lib/csv.rb (CSV#<<): honor explicity given encoding. based on
the patch by DAISUKE TANIWAKI <daisuketaniwaki AT gmail.com> at
[ruby-core:62113]. [Bug #9766]
----------------------------------------
Bug #9766: Add force_encoding option to csv
https://bugs.ruby-lang.org/issues/9766#change-47117
* Author: DAISUKE TANIWAKI
* Status: Closed
* Priority: Normal
* Assignee: James Gray
* Category: lib
* Target version: current: 2.2.0
* ruby -v: all
* Backport: 2.0.0: REQUIRED, 2.1: REQUIRED
----------------------------------------
Hi there,
I have a trouble when I use csv#generate with encoding 'Shift-JIS' option. =
I investigated it for a long time and found it is caused by compatibility w=
ithin "UTF-8" and "Shift-JIS". Since "Shift-JIS" can be converted to UTF-8,=
a row with UTF-8 strings added to the csv instance makes the encoding of w=
hole rows UTF-8.
Take a look at the code below.
https://github.com/dtaniwaki/ruby/blob/trunk/lib/csv.rb#L1658
Here's the code example.
```ruby
irb(main):002:0> s =3D generate(encoding: 'SJIS') do |csv|
csv << ['=E3=81=82']
end
=3D> ["=E3=81=82"]
irb(main):003:0> s
=3D> "=E3=81=82\n"
irb(main):004:0> s.encoding
=3D> #<Encoding:UTF-8>
```
I was intended to make SJIS encoded csv, but the result was UTF-8 csv. I th=
ink everyone think it should generate Shift-JIS encoded csv string, so coul=
d you consider to merge the change attached to this issue?
The expected result is here.
```ruby
irb(main):002:0> s =3D generate(encoding: 'SJIS', force_encoding: true) do =
|csv|
csv << ['=E3=81=82']
end
=3D> ["=E3=81=82"]
irb(main):003:0> s
=3D> "\x{E381}\x82\n"
irb(main):004:0> s.encoding
=3D> #<Encoding:Windows-31J>
```
---Files--------------------------------
csv.rb.diff (1.41 KB)
0001-csv.rb-honor-encoding-option.patch (2.64 KB)
--=20
https://bugs.ruby-lang.org/