[#35631] [Ruby 1.9 - Bug #4558][Open] TestSocket#test_closed_read fails after r31230 — Tomoyuki Chikanaga <redmine@...>

23 messages 2011/04/06

[#35632] [Ruby 1.9 - Bug #4559][Open] Proc#== does not match the documented behaviour — Adam Prescott <redmine@...>

13 messages 2011/04/06

[#35637] [Ruby 1.9 - Bug #4561][Open] 1.9.2 requires parentheses around argument of method call in an array, where 1.8.7 did not — Dave Schweisguth <redmine@...>

9 messages 2011/04/07

[#35734] [Ruby 1.9 - Feature #4574][Open] Numeric#within — redmine@...

16 messages 2011/04/13

[#35753] [Ruby 1.9 - Bug #4576][Open] Range#step miss the last value, if end-exclusive and has float number — redmine@...

61 messages 2011/04/14
[#39566] [Ruby 1.9 - Bug #4576] Range#step miss the last value, if end-exclusive and has float number — Marc-Andre Lafortune <ruby-core@...> 2011/09/15

[#39590] [Ruby 1.9 - Bug #4576] Range#step miss the last value, if end-exclusive and has float number — Marc-Andre Lafortune <ruby-core@...> 2011/09/16

[#39593] Re: [Ruby 1.9 - Bug #4576] Range#step miss the last value, if end-exclusive and has float number — Tanaka Akira <akr@...> 2011/09/16

2011/9/17 Marc-Andre Lafortune <[email protected]>:

[#39608] Re: [Ruby 1.9 - Bug #4576] Range#step miss the last value, if end-exclusive and has float number — Masahiro TANAKA <masa16.tanaka@...> 2011/09/17

I have not been watching ruby-core, but let me give a comment for this issu=

[#35765] [Ruby 1.9 - Bug #4579][Open] SecureRandom + OpenSSL may repeat with fork — redmine@...

27 messages 2011/04/15

[#35866] [Ruby 1.9 - Bug #4603][Open] lib/csv.rb: when the :encoding parameter is not provided, the encoding of CSV data is treated as ASCII-8BIT — yu nobuoka <nobuoka@...>

13 messages 2011/04/24

[#35879] [Ruby 1.9 - Bug #4610][Open] Proc#curry behavior is inconsistent with lambdas containing default argument values — Joshua Ballanco <jballanc@...>

11 messages 2011/04/25

[#35883] [Ruby 1.9 - Bug #4611][Open] [BUG] Segementation fault reported — Deryl Doucette <me@...>

15 messages 2011/04/25

[#35895] [Ruby 1.9 - Feature #4614][Open] [RFC/PATCH] thread_pthread.c: lower RUBY_STACK_MIN_LIMIT to 64K — Eric Wong <normalperson@...>

10 messages 2011/04/25

[ruby-core:35936] [Ruby 1.9 - Bug #4491] Some methods of Dir/File do not encode dirname/filename transparently

From: Yui NARUSE <redmine@...>
Date: 2011-04-28 05:15:50 UTC
List: ruby-core #35936
Issue #4491 has been updated by Yui NARUSE.

Assignee changed from Yui NARUSE to Usaku NAKAMURA


----------------------------------------
Bug #4491: Some methods of Dir/File do not encode dirname/filename transparently
http://redmine.ruby-lang.org/issues/4491

Author: Joey Zhou
Status: Assigned
Priority: Normal
Assignee: Usaku NAKAMURA
Category: M17N
Target version: 
ruby -v: ruby 1.9.2p180 (2011-02-18) [i386-mingw32]


My Ruby version is: ruby 1.9.2p180 (2011-02-18) [i386-mingw32]

My OS is Windows 7 (Simplified Chinese), its cmd.exe has a default codepage of CP936 (aka GBK), but I want my scripts to be written in UTF-8, so I've set the scripts' to UTF-8 and add "# encoding: utf-8" on the first line.

I find when I open a file, the filename will be encoded to the system's locale charmap automatically:

  puts File.open( "漢字file" ).readline                       #this will be fine, although the "漢字file" literal is UTF-8
  puts File.open( "漢字file".encode('utf-8') ).readline       #explicitly encoded
  puts File.open( "漢字file".encode('gbk') ).readline
  puts File.open( "漢字file".encode('big5') ).readline
  puts File.open( "漢字file".encode('shift_jis') ).readline   #all fine, all encoded to Encoding.locale_charmap before asking the OS for the file, no matter to what it's encoded here

I have tested many methods of File & Dir class, most of them have this intimate and convenient feature, but some are not:

  p Dir.entries( "漢字dir".encode('gbk') )                    # explicit encode is required, or "No such file or directory" error. Since my local charmap is gbk, it can not be encoded to utf-8, big5, shift_jis
  p Dir.glob( "漢字dir/*".encode('gbk') )
  Dir.foreach( "漢字dir".encode('gbk') ) {|f| puts f}
  Dir.open( "漢字dir".encode('gbk') ).each {|f| puts f}
  Dir.new( "漢字dir".encode('gbk') ).each {|f| puts f}        # all must explicitly encoded to locale_charmap (my situation is GBK)

and a File method require encoding too:

  puts File.absolute_path( "漢字file".encode('gbk') )

These methods may be missed, they may should act the same way as Dir.chdir("漢字dir") or File.open("漢字dir"), with a feature of transparently encoding.

Best regards.

Joey


-- 
http://redmine.ruby-lang.org

In This Thread

Prev Next