Project

General

Profile

Actions

Bug #179

closed

confusion about treating filesystem encoding

Added by usa (Usaku NAKAMURA) over 15 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
Backport:
[ruby-dev:35151]

Description

=begin
こんにちは、なかむら(う)です。

ぶら下げどころが決め切れなかった

先日成瀬さんが入れてくださったfilesystem encoding対応ですが、
rb_encodingとencoding indexを混同しています。
rb_encoding
の比較が有効なのかどうか確信がなかったので、encoding
indexで統一してみました。

rb_encoding*の比較が有効ならそっちに揃えた方がシンプルにな

るとは思います。

rb_utf8_encindex()はなんでないんだろう?

Index: io.c

--- io.c (revision 17396)
+++ io.c (working copy)
@@ -4107,16 +4107,16 @@ rb_open_file(int argc, VALUE *argv, VALU
static int fs_encoding;
int fname_encoding = rb_enc_get_index(fname);
if (!fs_encoding)

  •  fs_encoding = rb_filesystem_encoding();
    
  • if (rb_usascii_encoding() != fname_encoding
  •  && rb_ascii8bit_encoding() != fname_encoding
    
  •  fs_encoding = rb_enc_to_index(rb_filesystem_encoding());
    
  • if (rb_usascii_encindex() != fname_encoding
  •  && rb_ascii8bit_encindex() != fname_encoding
    

#if defined APPLE

  •  && rb_utf8_encoding() != fname_encoding
    
  •  && rb_enc_to_index(rb_utf8_encoding()) != fname_encoding
    

#endif
&& fs_encoding != fname_encoding) {
static VALUE fs_enc;
if (!fs_enc)

  •  fs_enc = rb_enc_from_encoding(fs_encoding);
    
  •  fs_enc = rb_enc_from_encoding(rb_enc_from_index(fs_encoding));
     fname = rb_str_transcode(fname, fs_enc);
    
    }
    }

    それでは。
    --
    U.Nakamura
    =end
Actions #1

Updated by naruse (Yui NARUSE) over 15 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r17403.
=end

Actions #2

Updated by naruse (Yui NARUSE) over 15 years ago

=begin
成瀬です。

U.Nakamura wrote:

rb_utf8_encindex()はなんでないんだろう?

そういえばこの理由ですが、単に現時点で UTF-8 の index を扱うコードが
Ruby 本体にないからです。
逆にいえば、US-ASCII や ASCII-8BIT があるのは、
string.c とかでそういうコードがあるから。

--
NARUSE, Yui

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0