以下の件で
Cygwin の bash に $'string' 形式でバックスラッシュエスケープシーケンス(backslash escape sequence)で UNICODE 文字を与えてみてたんだけど、期待通りの動作をしないケースを見つけた。
例えば、U+FF11[1] (FULLWIDTH DIGIT ONE) について以下のような結果となる。
あと echo も bash 組み込み関数版は同様の文字化けが生じる。
Ubuntu 16.04.5 LTS だと以下のように期待通りの結果が得られる。
Ubuntu 18.04.1 LTS Desktop の Live 版でも正常。
4.4.12(3)-release、バージョン固有の問題も考慮して、公式から拾ってきた以下のファイルを
う〜ん、困ったぞ、これは。
それはそうと、4.4.19 って bash 公式の tar ball にも git の tag にもないんだけど、これはどこにあるんだ??? ってしばらく悩んでたんだが、どうも、bash-4.4-patches 以下に差分パッチが積まれているようだ。
例えば、U+FF11[1] (FULLWIDTH DIGIT ONE) について以下のような結果となる。
$ echo $'\uff11' ퟿▒ $ echo $'\uff11'|xxd 00000000: ed9f bfed bc91 0a ....... $ echo $'\uff11'|iconv -f UTF-8 -t UTF-16BE|xxd 00000000: d7ff fffd 000a ......
$ echo $'\U0000ff11' ퟿▒ $ echo $'\U0000ff11'|xxd 00000000: ed9f bfed bc91 0a ....... $ echo $'\U0000FF11'|iconv -f UTF-8 -t UTF-16BE|xxd 00000000: d7ff fffd 000a ......
$ bash --version GNU bash, バージョン 4.4.12(3)-release (x86_64-unknown-cygwin) Copyright (C) 2016 Free Software Foundation, Inc. ライセンス GPLv3+: GNU GPL バージョン 3 またはそれ以降 <http://gnu.org/licenses/gpl.html> This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.見事に化けてるんだけど、1に続く2,3,4,...等も同様の結果になる。
あと echo も bash 組み込み関数版は同様の文字化けが生じる。
Ubuntu 16.04.5 LTS だと以下のように期待通りの結果が得られる。
$ echo $'\uff11' 1 $ echo $'\uff11'|xxd 00000000: efbc 910a .... $ echo $'\uff11'|iconv -f UTF-8 -t UTF-16BE|xxd 00000000: ff11 000a ....
$ echo $'\U0000ff11' 1 $ echo $'\U0000ff11'|xxd 00000000: efbc 910a .... $ echo $'\U0000ff11'|iconv -f UTF-8 -t UTF-16BE|xxd 00000000: ff11 000a ....
$ bash --version GNU bash, バージョン 4.3.48(1)-release (x86_64-pc-linux-gnu) Copyright (C) 2013 Free Software Foundation, Inc. ライセンス GPLv3+: GNU GPL バージョン 3 またはそれ以降 <http://gnu.org/licenses/gpl.html> This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
Ubuntu 18.04.1 LTS Desktop の Live 版でも正常。
ubuntu@ubuntu:~$ echo $'\uff11' 1
ubuntu@ubuntu:~$ bash --version GNU bash, version 4.4.19(1)-release (x86_64-pc-linux-gnu) Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
4.4.12(3)-release、バージョン固有の問題も考慮して、公式から拾ってきた以下のファイルを
$ sha1sum ../bash-4.4.12.tar.gz 7a840d0d1be7e6f089c80062fcafaa3cf69d292e ../bash-4.4.12.tar.gz以下の環境で ./configure && make してみた。
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.5 LTS Release: 16.04 Codename: xenial括弧内のバージョンが一致しないんだけど、ビルドして出来た 4.4.12(1)-release で実行した結果が以下。
$ ./bash --version GNU bash, バージョン 4.4.12(1)-release (x86_64-unknown-linux-gnu) Copyright (C) 2016 Free Software Foundation, Inc. ライセンス GPLv3+: GNU GPL バージョン 3 またはそれ以降 <http://gnu.org/licenses/gpl.html> This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. $ ./bash $ echo $'\uff11' 1 $ echo $BASH_VERSION 4.4.12(1)-release
う〜ん、困ったぞ、これは。
それはそうと、4.4.19 って bash 公式の tar ball にも git の tag にもないんだけど、これはどこにあるんだ??? ってしばらく悩んでたんだが、どうも、bash-4.4-patches 以下に差分パッチが積まれているようだ。
タグ
コメントをかく