Project

General

Profile

Bug #12184

Cygwin LANG=ja_JP.SJIS 環境でコマンドライン引数に日本語が渡せない

Added by k_satoda (Kazutoshi SATODA) almost 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-cygwin]
[ruby-dev:49519]

Description

Cygwin LANG=ja_JP.SJIS で ruby のコマンドライン引数に日本語を渡すと、
プログラム開始時点で ARGV 内の非 ASCII バイトがすべて "?" = 0x3F に置換
されてしまうようで、正しく動作しません。情報が潰れてしまっているので
プログラム側では対処不能な状態になります。

$ ruby -e 'a = ARGV[0]; p a, a.encoding, a.bytes' 'あ'
"??"
#<Encoding:Windows-31J>
[63, 63]

期待される結果は以下と同じ。

$ ruby -e 'a = "あ"; p a, a.encoding, a.bytes'
"あ"
#<Encoding:Windows-31J>
[130, 160]

LANG=ja_JP.UTF-8 なら問題ないようです。 ruby 2.0.x のときも
問題ありませんでした。

少し調べたところ、以下の変更で defined __CYGWIN__ の場合に固定で
define UTF8_PATH 1 されるようになっていて、これと実際の Cygwin の
動作
( LANG に設定されたエンコーディングで argv が設定される)とが
合っていないせいで問題が起こってるんじゃないかと思ってます。
https://github.com/ruby/ruby/commit/33ea2646b98adb49ae2e1781753bf22d33729ac0
https://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ruby.c?r1=48648&r2=48647&pathrev=48648

Associated revisions

Revision 88783116
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

ruby.c: fix command line encoding on cygwin

  • ruby.c: cygwin does not use w32_cmdvector, command line can be other than UTF-8. [ruby-dev:49519] [Bug #12184]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 54720
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

ruby.c: fix command line encoding on cygwin

  • ruby.c: cygwin does not use w32_cmdvector, command line can be other than UTF-8. [ruby-dev:49519] [Bug #12184]

Revision 54720
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

ruby.c: fix command line encoding on cygwin

  • ruby.c: cygwin does not use w32_cmdvector, command line can be other than UTF-8. [ruby-dev:49519] [Bug #12184]

Revision 54720
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

ruby.c: fix command line encoding on cygwin

  • ruby.c: cygwin does not use w32_cmdvector, command line can be other than UTF-8. [ruby-dev:49519] [Bug #12184]

Revision 54720
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

ruby.c: fix command line encoding on cygwin

  • ruby.c: cygwin does not use w32_cmdvector, command line can be other than UTF-8. [ruby-dev:49519] [Bug #12184]

Revision 7b70f0e2
Added by nagachika (Tomoyuki Chikanaga) almost 3 years ago

merge revision(s) 54720: [Backport #12184]

* ruby.c: cygwin does not use w32_cmdvector, command line can be
  other than UTF-8.  [ruby-dev:49519] [Bug #12184]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@54736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 54736
Added by nagachika (Tomoyuki Chikanaga) almost 3 years ago

merge revision(s) 54720: [Backport #12184]

* ruby.c: cygwin does not use w32_cmdvector, command line can be
  other than UTF-8.  [ruby-dev:49519] [Bug #12184]

Revision ed03c4d8
Added by usa (Usaku NAKAMURA) almost 3 years ago

merge revision(s) 54720: [Backport #12184]

* ruby.c: cygwin does not use w32_cmdvector, command line can be
  other than UTF-8.  [ruby-dev:49519] [Bug #12184]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@54770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 54770
Added by usa (Usaku NAKAMURA) almost 3 years ago

merge revision(s) 54720: [Backport #12184]

* ruby.c: cygwin does not use w32_cmdvector, command line can be
  other than UTF-8.  [ruby-dev:49519] [Bug #12184]

History

Updated by shyouhei (Shyouhei Urabe) almost 3 years ago

  • Status changed from Open to Assigned
  • Assignee set to nobu (Nobuyoshi Nakada)

Nobu will look into it.

#2

Updated by nobu (Nobuyoshi Nakada) almost 3 years ago

  • Status changed from Assigned to Closed

Applied in changeset r54720.


ruby.c: fix command line encoding on cygwin

  • ruby.c: cygwin does not use w32_cmdvector, command line can be other than UTF-8. [ruby-dev:49519] [Bug #12184]

Updated by nobu (Nobuyoshi Nakada) almost 3 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: DONTNEED, 2.2: REQUIRED, 2.3: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) almost 3 years ago

  • Backport changed from 2.1: DONTNEED, 2.2: REQUIRED, 2.3: REQUIRED to 2.1: DONTNEED, 2.2: REQUIRED, 2.3: DONE

ruby_2_3 r54736 merged revision(s) 54720.

Updated by usa (Usaku NAKAMURA) almost 3 years ago

  • Backport changed from 2.1: DONTNEED, 2.2: REQUIRED, 2.3: DONE to 2.1: DONTNEED, 2.2: DONE, 2.3: DONE

ruby_2_2 r54770 merged revision(s) 54720.

Also available in: Atom PDF