[#33561] open-uri problem — rubikitch@...
るびきちです。
[#33567] rational, complex and nuby — Tadayoshi Funaba <tadf@...>
ruby に rational と complex を組みこもうと試していて nuby という派生物
なかだです。
> 若干古い1.8.6がベースでしょうか。
なかだです。
> 2002/01/25版にその後の修正を手で追加した状態? ChangeLogをみたら、
なかだです。
> ちょっと見たところ、Enumerable#stable_sort_byがsortを使っている
原です。
[#33580] Re: cgi.rb再構築案 — "Makoto Kuwata" <kwa@...>
桑田といいます。
まつもと ゆきひろです
なかだです。
[#33611] Solaris で timeout.rb が Segmentation fault する。 — shiiya@...
はじめまして。椎屋と申します。
なかだです。
椎屋です。反応ありがとうございます。
なかだです。
さとうふみやす @ OSS テクノロジです。
In article <87r6foys1z.wl%[email protected]>,
At Fri, 8 Feb 2008 14:00:35 +0900,
In article <87prv8yovi.wl%[email protected]>,
とみたです。
In article <[email protected]>,
[#33621] EUC-KR <-> UTF-8 transition table — "Park Ji-In" <tisphie@...>
朴 芝印です。
成瀬です。
At 05:00 08/02/07, NARUSE, Yui wrote:
朴 芝印です。
[#33628] encdet.rb — Tanaka Akira <akr@...>
前から考えていたのですが、ファイル先頭の magic comment や
まつもと ゆきひろです
In article <[email protected]>,
須藤です。
In article <[email protected]>,
須藤です。
In article <[email protected]>,
[#33646] require/load/autoload の encoding オプション — Hidetoshi NAGAI <nagai@...>
永井@知能.九工大です.
まつもと ゆきひろです
永井@知能.九工大です.
[#33662] rational, complex and mathn — Tadayoshi Funaba <tadf@...>
rational は floor、truncate、ceil、round を定義していません。Numeric
他にも問題、課題はあると思います。すぐに解決できるものと、そうでないも
ひとつ書き忘れました。
まつもと ゆきひろです
> 原さんのrationalは導入予定がありますので、この機会にもう一度
原です。
> 前にふなばさんと個人的なメールのやりとりで、結局また私がrationalをまと
原です。
> > それなりに速くはなるし、単純なところでそれなりに満足していますが、一度、
nurat 0.0.2 を出しました (ついでに nucomp も)。
仕様を確認していきたいと思います。
まつもと ゆきひろです
原です。
> > new!はRubyで実装しているためにだけ必要なので、Cで実装するな
原です。
> Rational::Unify が定義されているときは、Rational.new(1,1) で Integer
> Rational() は、1つか2つの引数をとる。
> 実際的に重要な機能が Rational() という名前で固定されるのはクラスの定義
もうあまり手を入れないでおこうと思ったのです、つい手を入れてしまいまし
原です。
ちょっと実験してみました。原さんの rational は、かけ算割り算が速いので、
で、考えていたんですが、目的は、最速の rational を作ることではなくて、
原です。
成瀬です。
まつもと ゆきひろです
> はい。Complexについても1.9の間に組み込んでよいと思います。
まつもと ゆきひろです
nurat を組みこんでみました。最低限必要な修正だけになっていると思います。
rational と complex を 1.9 に組みこむ作業をしました。
異議がなければ、若干の手直しの後、次週末にでも trunk にコミットしよう
> 異議がなければ、若干の手直しの後、次週末にでも trunk にコミットしよう
まつもと ゆきひろです
[#33674] erb.rb の仕様について — "Makoto Kuwata" <kwa@...>
桑田といいます。
[#33676] Suggestion: Proc#curry — "Yusuke ENDOH" <mame@...>
遠藤と申します。
[#33679] bigdecimal — Tadayoshi Funaba <tadf@...>
bigdecimal/math.rb の BigMath は、利用者が include してつかうことを前
Integer や Float に比べると、BigDicimal() は、1 や 1.1 を受けつけない、
斎藤と申します。
> 仮にBigDecimal(1.1)を、(二進小数として)受け付けると、「BigDecimalでは、
まつもと ゆきひろです
[#33699] trunk: インストールファイルのアクセス権 — pegacorn <subscriber.jp@...>
trunk で、インストールファイルのアクセス権が適切に設定されないものが
[#33712] Array の product の戻り値 — "Hideo Konami" <konami@...>
小波です。
[#33726] Re: [ruby-cvs:22680] Ruby:r15443 (trunk): * bootstraptest/runner.rb, bootstraptest/test_method.rb, enc/depend, — "U.Nakamura" <usa@...>
こんにちは、なかむら(う)です。
成瀬です。
In article <[email protected]>,
Tanaka Akira wrote:
こんにちは、なかむら(う)です。
成瀬です。
[#33825] Ruby M17N 会議の議事録 — "NARUSE, Yui" <naruse@...>
成瀬です。
[#33837] spec of Rational — Shin-ichiro HARA <sinara@...>
原です。
[#33838] 文字列処理の高速化 ? — Martin Duerst <duerst@...>
ただの一例ですが、先週の金曜日に松本さんに見せたときに
[#33843] IO.copy_stream — Tanaka Akira <akr@...>
IO.copy_stream をつけるのはどうでしょうか。
[#33889] Re: [ ruby-Bugs-17454 ] irb crash while iterating over all objects — Urabe Shyouhei <shyouhei@...>
卜部です。ちょっとお知恵を拝借したく。
ミスって送信ボタン押しちゃった
こんにちは、なかむら(う)です。
なかだです。
Nobuyoshi Nakada さんは書きました:
豊福です。
まつもと ゆきひろです
豊福です。
まつもと ゆきひろです
豊福です。
まつもと ゆきひろです
豊福です。
[#33894] character encodings differ: US-ASCII and dummy encoding — Kazuhiro NISHIYAMA <zn@...>
西山和広です。
まつもと ゆきひろです
[#33916] UTF_16LE.dummy? returns false — sheepman <sheepman@...>
こんにちは sheepman です。
[#33926] --host=i586-mingw32msvc — Kouhei Sutou <kou@...>
須藤です。
[#33937] patch for ruby_1_8_6/lib/rexml/element.rb@12852 — oshida@...
押田です。
[#33943] warning about space before argument parentheses — Nobuyoshi Nakada <nobu@...>
なかだです。
[ruby-dev:33628] encdet.rb
前から考えていたのですが、ファイル先頭の magic comment や
BOM を調べて encoding を設定してくれるライブラリを添付するの
はどうでしょうか。
% head -1 lib/rexml/rexml.rb
# -*- encoding: utf-8 -*-
% ./ruby -Ilib -rencdet -e '
EncDet.open("lib/rexml/rexml.rb") {|f|
p f.external_encoding
}'
#<Encoding:UTF-8>
というように検出できます。
とりあえず、lib/rdoc/rdoc.rb で適当にやっているのをこういう
のに変えたいんですが。
Index: lib/encdet.rb
===================================================================
--- lib/encdet.rb (revision 0)
+++ lib/encdet.rb (revision 0)
@@ -0,0 +1,96 @@
+module EncDet
+ def EncDet.open(fname, mode='r')
+ if block_given?
+ File.open(fname, mode) {|f|
+ f.set_encoding detect_encoding(f)
+ yield f
+ }
+ else
+ f = File.open(fname, mode)
+ f.set_encoding detect_encoding(f)
+ f
+ end
+ end
+
+ PEEKSIZE = 4096
+
+ Detectors = {}
+
+ Detectors[:magic_comment] = lambda {|buf|
+ if /\A#!/ =~ buf
+ numlines = 2
+ else
+ numlines = 1
+ end
+ target = ''
+ buf.each_line {|line|
+ target << line
+ numlines -= 1
+ break if numlines == 0
+ }
+ if /coding[:=][ \t]*(?<encname>[\w.-]+)[^\w.-]/ =~ target
+ begin
+ Encoding.find(encname)
+ rescue ArgumentError
+ Encoding::ASCII_8BIT
+ end
+ else
+ if numlines == 0 && /\n\z/ =~ target
+ :not_found
+ else
+ :more_bytes
+ end
+ end
+ }
+
+ Detectors[:utf_bom] = lambda {|buf|
+ h = {
+ "UTF-8" => /\A\xEF(?:\xBB(\xBF)?)?/n,
+ "UTF-16BE" => /\A\xFE(\xFF)?/n,
+ "UTF-16LE" => /\A\xFF(\xFE)?/n,
+ }
+ result = :not_found
+ h.each {|name, pat|
+ if pat =~ buf
+ if $1
+ result = Encoding.find(name)
+ break
+ end
+ result = :more_bytes
+ end
+ }
+ result
+ }
+
+ def EncDet.detect_encoding(f)
+ result = nil
+ detectors = Detectors.dup
+ buf = ''
+ while buf.bytesize < PEEKSIZE
+ begin
+ buf << f.readpartial(PEEKSIZE - buf.bytesize)
+ rescue EOFError
+ break
+ end
+ next_detectors = {}
+ detectors.each {|name, det|
+ r = det.call(buf)
+ case r
+ when :not_found
+ next
+ when :more_bytes
+ next_detectors[name] = det
+ when Encoding
+ result = r
+ break
+ else
+ raise TypeError, "unexpected detection result by #{name}: #{r.inspect}"
+ end
+ }
+ break if next_detectors.empty? || result
+ detectors = next_detectors
+ end
+ f.ungetc buf
+ result || f.external_encoding
+ end
+end
Index: test/test-encdet.rb
===================================================================
--- test/test-encdet.rb (revision 0)
+++ test/test-encdet.rb (revision 0)
@@ -0,0 +1,41 @@
+require 'test/unit'
+require 'encdet'
+
+class TestEncDet < Test::Unit::TestCase
+
+ def check_detect_encoding(content, enc)
+ r, w = IO.pipe
+ w.write content
+ w.close
+ result = EncDet.detect_encoding(r)
+ assert_equal(Encoding.find(enc), result)
+ ensure
+ r.close if r && !r.closed?
+ w.close if w && !w.closed?
+ end
+
+ def test_magic_comment
+ [
+ ["-*- coding: utf-8 -*-\n\u{3042}\n", "UTF-8"],
+ ["-*- coding: euc-jp -*-\n\xa4\xa2\n", "EUC-JP"],
+ ["#!/bin/sh\n# -*- coding: utf-8 -*-\n\u{3042}\n", "UTF-8"],
+ ["#!/bin/sh\n# -*- coding: euc-jp -*-\n\xa4\xa2\n", "EUC-JP"],
+ ["\n-*- coding: utf-8 -*-\n\u{3042}\n", Encoding.locale_charmap],
+ ["\n-*- coding: euc-jp -*-\n\xa4\xa2\n", Encoding.locale_charmap],
+ ].each {|content, enc|
+ check_detect_encoding(content, enc)
+ }
+ end
+
+ def test_bom
+ [
+ ["\xef\xbb\xbfab", "UTF-8"],
+ ["\xfe\xff\0a\0b", "UTF-16BE"],
+ ["\xff\xfea\0b\0", "UTF-16LE"],
+ ].each {|content, enc|
+ check_detect_encoding(content, enc)
+ }
+ end
+
+end
+
--
[田中 哲][たなか あきら][Tanaka Akira]