[#30408] Ruby 1.8.6 preview2 has been released — "Akinori MUSHA" <knu@...>

 Ruby 1.8.6 preview2 をリリースしました。

20 messages 2007/02/24
[#30414] fail to autoload at $SAFE==4 (Re: Ruby 1.8.6 preview2 has been released) — Hidetoshi NAGAI <nagai@...> 2007/02/25

永井@知能.九工大です.

[#30418] Re: fail to autoload at $SAFE==4 (Re: Ruby 1.8.6 preview2 has been released) — Nobuyoshi Nakada <nobu@...> 2007/02/25

なかだです。

[ruby-dev:30439] Re: MIME decoding confused by non-MIME characters

From: Urabe Shyouhei <shyouhei@...>
Date: 2007-02-27 12:00:02 UTC
List: ruby-dev #30439
-devに振ってみる。

Brian Candler wrote:
> Could someone who has bleeding-edge Ruby installed please test the
> following?
>
> irb(main):001:0> RUBY_VERSION
> => "1.8.5"
> irb(main):002:0> a = "b2s="
> => "b2s="
> irb(main):003:0> b = "\xef\xbb\xbf" + a
> => "\357\273\277b2s="
> irb(main):004:0> a.unpack("m")
> => ["ok"]
> irb(main):005:0> b.unpack("m")
> => ["$\000\e\332"]
>
> That is, non-printable characters (here a UTF8-encoded BOM) are causing MIME
> unpack to return garbage.
>   

これどうすべきだと思います? NKFですら

irb(main):001:0> NKF.nkf "-W8emB", "\xef\xbb\xbfb2s="
=> "\e"

こんな感じなので、「そういうものです」と言い切ってしまうのもありといえば
ありな気がしますが...

(参考)他の言語ではどうなってるかというと

% perl -mMIME::Base64 -e'print MIME::Base64::decode_base64("\xef\xbb\277b2s=")'
ok
% python
Python 2.4.4 (#2, Jan 13 2007, 17:50:26) 
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from base64 import b64decode
>>> b64decode("\xef\xbb\277b2s=")
'ok'
>>> 
% php -r 'echo base64_decode("\xef\xbb\277b2s=");'
ok


In This Thread

Prev Next