Forum: Ruby-dev * lib/csv.rb: Failure test_inspect_is_ascii_8bit_encoded(TestCSVRow)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
TAKANO Mitsuhiro (Guest)
on 2008-10-24 08:45
(Received via mailing list)
高野です。

----
1) Failure:
test_inspect_is_ascii_8bit_encoded(TestCSVRow)
[/home/takano/ruby/test/csv/test_
row.rb:300]:
<"ASCII-8BIT"> expected but was
<"US-ASCII">.
----

についてのパッチです。

# ほんとにこんなんでいいのかな・・・
# 文字コード周りに詳しい方教えてくださいっ。m(_ _)m
Kazuhiro NISHIYAMA (Guest)
on 2008-10-24 09:28
(Received via mailing list)
$B@>;3OB9-$G$9!#(B

At Fri, 24 Oct 2008 13:42:54 +0900,
TAKANO Mitsuhiro wrote:
> $B$K$D$$$F$N%Q%C%A$G$9!#(B
>
> # $B$[$s$H$K$3$s$J$s$G$$$$$N$+$J!&!&!&(B
> # $BJ8;z%3!<%I<~$j$K>\$7$$J}65$($F$/$@$5$$$C!#(Bm(_ _)m

test/ruby/test_array.rb$B$H0l=o$K<B9T$9$k$H:F8=$9#r$h$&$G!"(B$,=""$B$H(B

>> ("".encode("US-ASCII")+"".encode("ASCII-8BIT")).encoding
=> #<Encoding:US-ASCII>
>> ("".encode("ASCII-8BIT")+"".encode("US-ASCII")).encoding
=> #<Encoding:ASCII-8BIT>

$B$,860x$N$h$&$K;W$$$^$7$?!#(B


>      end
>    end

$B%0%m!<%P%k$J4D6-$rJQ99$7$FLa$7$F$J$$%F%9%H$,0-$$ItJ,$H(B
$BL50z?t$N(Bjoin$B$r;H$C$F$$$k$H$3$m$NN>J}$rD>$9$J$i$3$s$J(B
$B46$8$G$7$g$&$+!#(B

Index: lib/csv.rb
===================================================================
--- lib/csv.rb  (revision 19903)
+++ lib/csv.rb  (working copy)
@@ -495,7 +495,7 @@
                ":" << field.inspect
       end
       str << ">"
-      str.map { |s| s.encode("ASCII-8BIT") }.join
+      str.map { |s| s.encode("ASCII-8BIT")
}.join("".encode("ASCII-8BIT"))
     end
   end

Index: test/ruby/test_array.rb
===================================================================
--- test/ruby/test_array.rb  (revision 19903)
+++ test/ruby/test_array.rb  (working copy)
@@ -814,6 +814,8 @@
     s = a.join
     assert_equal(true, s.tainted?)
     assert_equal(true, s.untrusted?)
+  ensure
+    $, = nil
   end

   def test_last
Index: test/ruby/test_hash.rb
===================================================================
--- test/ruby/test_hash.rb  (revision 19903)
+++ test/ruby/test_hash.rb  (working copy)
@@ -627,6 +627,7 @@
     assert_equal(h.inspect, h.to_s)
     h = @cls[]
     assert_equal(h.inspect, h.to_s)
+  ensure
     $, = nil
   end
Martin D. (Guest)
on 2008-10-24 10:54
(Received via mailing list)
[forwarded from ruby-dev to ruby-core, with translation(t)/comments(c)]


At 13:42 08/10/24, TAKANO Mitsuhiro wrote:
>$B9bLn$G$9!#(B
>

(t) This is Takano. This is a patch regarding

>
># $B$[$s$H$K$3$s$J$s$G$$$$$N$+$J!&!&!&(B
># $BJ8;z%3!<%I<~$j$K>\$7$$J}65$($F$/$@$5$$$C!#(Bm(_ _)m

(t) I'm not sure this is the right thing to do,...
(t) Somebody who knows about character encoding, please help.

(c) The patch below doesn't look like something we want
    programmers to have to do. Either we need some change
    in the test, or we need some some fix in the logic.
    "US-ASCII" is in all respecs a subset of "ASCII-8BIT",
    so things will work just fine.

    Regards,    Martin.

>+      str.map { |s| s.encode("ASCII-8BIT") }.join.encode("ASCII-8BIT")
>     end
>   end


#-#-#  Martin J. Du"rst, Assoc. Professor, Aoyama Gakuin University
#-#-#  http://www.sw.it.aoyama.ac.jp 
mailto:removed_email_address@domain.invalid
Yukihiro M. (Guest)
on 2008-10-24 13:20
(Received via mailing list)
$B$^$D$b$H(B $B$f$-$R$m$G$9(B

In message "Re: [ruby-dev:36898] Re: * lib/csv.rb: Failure
test_inspect_is_ascii_8bit_encoded(TestCSVRow)"
    on Fri, 24 Oct 2008 14:26:04 +0900, Kazuhiro NISHIYAMA
<removed_email_address@domain.invalid> writes:

|test/ruby/test_array.rb$B$H0l=o$K<B9T$9$k$H:F8=$9#r$h$&$G!"(B$,=""$B$H(B
|
|>> ("".encode("US-ASCII")+"".encode("ASCII-8BIT")).encoding
|=> #<Encoding:US-ASCII>
|>> ("".encode("ASCII-8BIT")+"".encode("US-ASCII")).encoding
|=> #<Encoding:ASCII-8BIT>
|
|$B$,860x$N$h$&$K;W$$$^$7$?!#(B

$B$"$j$,$H$&$4$6$$$^$9!#(B

|$B%0%m!<%P%k$J4D6-$rJQ99$7$FLa$7$F$J$$%F%9%H$,0-$$ItJ,$H(B
|$BL50z?t$N(Bjoin$B$r;H$C$F$$$k$H$3$m$NN>J}$rD>$9$J$i$3$s$J(B
|$B46$8$G$7$g$&$+!#(B

$B0-$$$N$OA0<T$G!"L50z?t$N(Bjoin$B$K$O:a$,$"$j$^$;$s(B($B$H;W$$$^$9(B)$B!#(B
$B$N$G!"A0<T$KBP$9$k%Q%C%A$@$1Ev$F$^$9!#(B
James G. (Guest)
on 2008-10-25 04:57
(Received via mailing list)
On Oct 24, 2008, at 1:52 AM, Martin D. wrote:

> [forwarded from ruby-dev to ruby-core, with translation(t)/
> comments(c)]

Thanks so much for doing this.  You are really helping us bridge the
gap between the two communities.

>> row.rb:300]:
> (t) Somebody who knows about character encoding, please help.
>
> (c) The patch below doesn't look like something we want
>    programmers to have to do. Either we need some change
>    in the test, or we need some some fix in the logic.
>    "US-ASCII" is in all respecs a subset of "ASCII-8BIT",
>    so things will work just fine.

I loosened the tests to check for an ASCII compatible Encoding
instead.  Hopefully this fixes the issue for everyone, but please let
me know if that's not the case.

James Edward G. II
This topic is locked and can not be replied to.