ruby-dev (Japanese) list archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-dev:50801] [Ruby trunk Feature#15931] encoding for CESU-8
       [not found] <redmine.issue-15931.20190617072039@ruby-lang.org>
@ 2019-06-17  7:20 ` artonx
  2019-06-26  9:13 ` [ruby-dev:50803] " duerst
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: artonx @ 2019-06-17  7:20 UTC (permalink / raw)
  To: ruby-dev

Issue #15931 has been reported by arton (Akio Tajima).

----------------------------------------
Feature #15931: encoding for CESU-8
https://bugs.ruby-lang.org/issues/15931

* Author: arton (Akio Tajima)
* Status: Open
* Priority: Normal
* Assignee: naruse (Yui NARUSE)
* Target version: 2.7
----------------------------------------
RubyとJavaのブリッジを開発していて、文字列の変換処理で困っています。
現象)
JavaのUTF-8は非標準的な形式(https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/types.html#modified_utf_8_strings)なので、Ruby側の文字列をそのままUTF-8にエンコードして与えると、Java側ではサロゲートペアに相当する文字を正しく認識できません。
お願い)
Java固有の拡張UTF-8は一般性が欠けていると考えられますが、ほぼ互換のCESU-8(https://www.unicode.org/reports/tr26/tr26-4.html)は、IANAの文字セットにも登録されていて通信などでそれなりに利用されているようなので、RubyのEncodingでサポートしていただきたいと思います。

よろしくご検討ください。



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-dev:50803] [Ruby trunk Feature#15931] encoding for CESU-8
       [not found] <redmine.issue-15931.20190617072039@ruby-lang.org>
  2019-06-17  7:20 ` [ruby-dev:50801] [Ruby trunk Feature#15931] encoding for CESU-8 artonx
@ 2019-06-26  9:13 ` duerst
  2019-06-26 23:50 ` [ruby-dev:50805] " naruse
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: duerst @ 2019-06-26  9:13 UTC (permalink / raw)
  To: ruby-dev

Issue #15931 has been updated by duerst (Martin Dürst).


念のために言っておきますが、https://www.unicode.org/reports/tr26/tr26-4.html に「It is not intended nor recommended as an encoding used for open information exchange.」と書いてあります。くれぐれもよくご注意ください。

さらに、https://www.unicode.org/reports/tr26/ に「CESU-8 documents an obsolete internal-use encoding scheme for Unicode identical to UTF-8 except for its representation of supplementary characters.」と「CESU-8 is not intended nor recommended as an encoding used for open information exchange. Therefore, there is no need to develop this report any further.」と書いてあります。

これはあくまでも完全に Java 側の問題で、なぜ Ruby 側で対応しないといけないのか全く分かりません。できれば Revision 7f64a0b4 を逆戻りしていただきたいです。Ruby が文字コードの混乱に貢献してほしくないからです。

----------------------------------------
Feature #15931: encoding for CESU-8
https://bugs.ruby-lang.org/issues/15931#change-78888

* Author: arton (Akio Tajima)
* Status: Closed
* Priority: Normal
* Assignee: naruse (Yui NARUSE)
* Target version: 2.7
----------------------------------------
RubyとJavaのブリッジを開発していて、文字列の変換処理で困っています。
現象)
JavaのUTF-8は非標準的な形式 (https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/types.html#modified_utf_8_strings) なので、Ruby側の文字列をそのままUTF-8にエンコードして与えると、Java側ではサロゲートペアに相当する文字を正しく認識できません。
お願い)
Java固有の拡張UTF-8は一般性が欠けていると考えられますが、ほぼ互換のCESU-8 (https://www.unicode.org/reports/tr26/tr26-4.html) は、IANAの文字セットにも登録されていて通信などでそれなりに利用されているようなので、RubyのEncodingでサポートしていただきたいと思います。

よろしくご検討ください。



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-dev:50805] [Ruby trunk Feature#15931] encoding for CESU-8
       [not found] <redmine.issue-15931.20190617072039@ruby-lang.org>
  2019-06-17  7:20 ` [ruby-dev:50801] [Ruby trunk Feature#15931] encoding for CESU-8 artonx
  2019-06-26  9:13 ` [ruby-dev:50803] " duerst
@ 2019-06-26 23:50 ` naruse
  2019-06-27 10:28 ` [ruby-dev:50806] " duerst
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: naruse @ 2019-06-26 23:50 UTC (permalink / raw)
  To: ruby-dev

Issue #15931 has been updated by naruse (Yui NARUSE).


duerst (Martin Dürst) wrote:
> 念のために言っておきますが、https://www.unicode.org/reports/tr26/tr26-4.html に「It is not intended nor recommended as an encoding used for open information exchange.」と書いてあります。くれぐれもよくご注意ください。
> 
> さらに、https://www.unicode.org/reports/tr26/ に「CESU-8 documents an obsolete internal-use encoding scheme for Unicode identical to UTF-8 except for its representation of supplementary characters.」と「CESU-8 is not intended nor recommended as an encoding used for open information exchange. Therefore, there is no need to develop this report any further.」と書いてあります。
> 
> これはあくまでも完全に Java 側の問題で、なぜ Ruby 側で対応しないといけないのか全く分かりません。できれば Revision 7f64a0b4 を逆戻りしていただきたいです。Ruby が文字コードの混乱に貢献してほしくないからです。

「RubyとJavaのブリッジ」と書かれていますが、リンク先を見るとこれはJNI (Java Native Interface) の話で、要するにJavaからはCESU-8でデータが渡ってくるということです。
渡ってきたらもうRubyで扱うしかないのでこれはRubyの問題です。

Rubyの問題であり、実際にユーザーが少なくとも一人いるならばこれは対応するべきです。

文字コードの混乱という懸念は10年前ならあったでしょうが、もはやUTF-8が最高にして唯一の文字コードであることは誰の目にも明らかです。
もっとUTF-8を信じてあげてください、revertはしません。

----------------------------------------
Feature #15931: encoding for CESU-8
https://bugs.ruby-lang.org/issues/15931#change-78900

* Author: arton (Akio Tajima)
* Status: Closed
* Priority: Normal
* Assignee: naruse (Yui NARUSE)
* Target version: 2.7
----------------------------------------
RubyとJavaのブリッジを開発していて、文字列の変換処理で困っています。
現象)
JavaのUTF-8は非標準的な形式 (https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/types.html#modified_utf_8_strings) なので、Ruby側の文字列をそのままUTF-8にエンコードして与えると、Java側ではサロゲートペアに相当する文字を正しく認識できません。
お願い)
Java固有の拡張UTF-8は一般性が欠けていると考えられますが、ほぼ互換のCESU-8 (https://www.unicode.org/reports/tr26/tr26-4.html) は、IANAの文字セットにも登録されていて通信などでそれなりに利用されているようなので、RubyのEncodingでサポートしていただきたいと思います。

よろしくご検討ください。



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-dev:50806] [Ruby trunk Feature#15931] encoding for CESU-8
       [not found] <redmine.issue-15931.20190617072039@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2019-06-26 23:50 ` [ruby-dev:50805] " naruse
@ 2019-06-27 10:28 ` duerst
  2019-07-14  5:21 ` [ruby-dev:50813] [Ruby master " duerst
  2019-08-02  8:19 ` [ruby-dev:50826] " artonx
  5 siblings, 0 replies; 6+ messages in thread
From: duerst @ 2019-06-27 10:28 UTC (permalink / raw)
  To: ruby-dev

Issue #15931 has been updated by duerst (Martin Dürst).


naruse (Yui NARUSE) wrote:

> 文字コードの混乱という懸念は10年前ならあったでしょうが、もはやUTF-8が最高にして唯一の文字コードであることは誰の目にも明らかです。
> もっとUTF-8を信じてあげてください

勇気づけありがとうございます。書き込みの一つの目的は、CESU-8 の立場をはっきりさせることでした。


> 「RubyとJavaのブリッジ」と書かれていますが、リンク先を見るとこれはJNI (Java Native Interface) の話で、要するにJavaからはCESU-8でデータが渡ってくるということです。
> 渡ってきたらもうRubyで扱うしかないのでこれはRubyの問題です。

本来 Java の問題には変わりがありませんが、Ruby で対応する必要があるかもしれません。しかし、対応の仕方はいろいろあります。

現在の対応だと、CESU-8 は dummy ではなく、本格的なものになっています:
```
$ ./ruby -e 'Encoding::CESU_8.dummy?.display'
false
```

大文字小文字の変換さえできます:
```
$ ./ruby -e 'puts "Dürst".force_encoding("CESU-8").upcase.force_encoding("UTF-8")'
DÜRST
```

しかし、UTF-8 への変換はできません:
```
$ ./ruby -e '"Dürst".encode("CESU-8")'
Traceback (most recent call last):
        1: from -e:1:in `<main>'
-e:1:in `encode': code converter not found (UTF-8 to CESU-8) (Encoding::ConverterNotFoundError)
```

CESU-8 と UTF-8 の立場を考えると、むしろ逆の方がいいのではないでしょうか。Encoding は dummy でよいが、変換は用意した方がいいのではないか、ということです。少なくとも提案者に一回確認した方がよかったのではないでしょうか。

> Rubyの問題であり、実際にユーザーが少なくとも一人いるならばこれは対応するべきです。

「実際にユーザーが少なくとも一人いる」は Ruby に新機能を導入基準としてで今まで何回通用したなのでしょうか。これから何回通用するでしょうか。

----------------------------------------
Feature #15931: encoding for CESU-8
https://bugs.ruby-lang.org/issues/15931#change-78911

* Author: arton (Akio Tajima)
* Status: Closed
* Priority: Normal
* Assignee: naruse (Yui NARUSE)
* Target version: 2.7
----------------------------------------
RubyとJavaのブリッジを開発していて、文字列の変換処理で困っています。
現象)
JavaのUTF-8は非標準的な形式 (https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/types.html#modified_utf_8_strings) なので、Ruby側の文字列をそのままUTF-8にエンコードして与えると、Java側ではサロゲートペアに相当する文字を正しく認識できません。
お願い)
Java固有の拡張UTF-8は一般性が欠けていると考えられますが、ほぼ互換のCESU-8 (https://www.unicode.org/reports/tr26/tr26-4.html) は、IANAの文字セットにも登録されていて通信などでそれなりに利用されているようなので、RubyのEncodingでサポートしていただきたいと思います。

よろしくご検討ください。



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-dev:50813] [Ruby master Feature#15931] encoding for CESU-8
       [not found] <redmine.issue-15931.20190617072039@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2019-06-27 10:28 ` [ruby-dev:50806] " duerst
@ 2019-07-14  5:21 ` duerst
  2019-08-02  8:19 ` [ruby-dev:50826] " artonx
  5 siblings, 0 replies; 6+ messages in thread
From: duerst @ 2019-07-14  5:21 UTC (permalink / raw)
  To: ruby-dev

Issue #15931 has been updated by duerst (Martin Dürst).

Status changed from Closed to Open

Reopened to consider whether we can make the CESU-8 encoding a dummy encoding now that we have the encoding conversion from/to UTF-8 (see issue #15995).

----------------------------------------
Feature #15931: encoding for CESU-8
https://bugs.ruby-lang.org/issues/15931#change-79383

* Author: arton (Akio Tajima)
* Status: Open
* Priority: Normal
* Assignee: naruse (Yui NARUSE)
* Target version: 2.7
----------------------------------------
RubyとJavaのブリッジを開発していて、文字列の変換処理で困っています。
現象)
JavaのUTF-8は非標準的な形式 (https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/types.html#modified_utf_8_strings) なので、Ruby側の文字列をそのままUTF-8にエンコードして与えると、Java側ではサロゲートペアに相当する文字を正しく認識できません。
お願い)
Java固有の拡張UTF-8は一般性が欠けていると考えられますが、ほぼ互換のCESU-8 (https://www.unicode.org/reports/tr26/tr26-4.html) は、IANAの文字セットにも登録されていて通信などでそれなりに利用されているようなので、RubyのEncodingでサポートしていただきたいと思います。

よろしくご検討ください。



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-dev:50826] [Ruby master Feature#15931] encoding for CESU-8
       [not found] <redmine.issue-15931.20190617072039@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2019-07-14  5:21 ` [ruby-dev:50813] [Ruby master " duerst
@ 2019-08-02  8:19 ` artonx
  5 siblings, 0 replies; 6+ messages in thread
From: artonx @ 2019-08-02  8:19 UTC (permalink / raw)
  To: ruby-dev

Issue #15931 has been updated by arton (Akio Tajima).


提案者です。議論ありがとうございます。
過去のRubyのバージョンのサポートも必要なのでブリッジ自身でもUTF-8とCESU-8の相互変換は行います。その意味ではencodeメソッドは必ずしも必要ありません(当方の認識不足もあって、最初にイッシューを登録したときとは多少状況が変わっています)。
しかし、ユーザーが与えたStringのエンコードがUTF-8の場合、ブリッジとしては\u10000以上の文字が含まれているかどうかの判定に文字列の全舐めが必要です。また必要であればCESU-8への変換処理が必要となります。これらの判定と変換は当然オーバーヘッドです。
もしユーザーが\u10000未満の文字しか利用しないことを知っていれば、あらかじめ文字列のencodingにCESU-8を指定することで、ブリッジは上記のオーバーヘッドなしで指定された文字列をJavaに与えることが可能となります。この場合、ブリッジに与える直前にforce_encoding('CESU-8')としても良いので、その意味ではdummyではだめか? と言われると問題ないとも思います。
逆方向のJavaから受け取った文字列については現状、すべてUTF-8としているので、こちらについてはCESU-8を与えることはないと思います。
提案当初は、Java→Ruby方向についてはオーバーヘッドが無いことからCESU-8のままユーザーへ与えることを想定したのですが、過去のバージョンのことを考えると、変換処理を記述する必要性に変わりなく、であればUTF-8にするほうがリーズナブルだという結論となったので、この点はこちらの考えが変わったので申し訳ない。




----------------------------------------
Feature #15931: encoding for CESU-8
https://bugs.ruby-lang.org/issues/15931#change-80346

* Author: arton (Akio Tajima)
* Status: Open
* Priority: Normal
* Assignee: naruse (Yui NARUSE)
* Target version: 2.7
----------------------------------------
RubyとJavaのブリッジを開発していて、文字列の変換処理で困っています。
現象)
JavaのUTF-8は非標準的な形式 (https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/types.html#modified_utf_8_strings) なので、Ruby側の文字列をそのままUTF-8にエンコードして与えると、Java側ではサロゲートペアに相当する文字を正しく認識できません。
お願い)
Java固有の拡張UTF-8は一般性が欠けていると考えられますが、ほぼ互換のCESU-8 (https://www.unicode.org/reports/tr26/tr26-4.html) は、IANAの文字セットにも登録されていて通信などでそれなりに利用されているようなので、RubyのEncodingでサポートしていただきたいと思います。

よろしくご検討ください。



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-08-02  8:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-15931.20190617072039@ruby-lang.org>
2019-06-17  7:20 ` [ruby-dev:50801] [Ruby trunk Feature#15931] encoding for CESU-8 artonx
2019-06-26  9:13 ` [ruby-dev:50803] " duerst
2019-06-26 23:50 ` [ruby-dev:50805] " naruse
2019-06-27 10:28 ` [ruby-dev:50806] " duerst
2019-07-14  5:21 ` [ruby-dev:50813] [Ruby master " duerst
2019-08-02  8:19 ` [ruby-dev:50826] " artonx

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).