作者: Bruce.
日時: 2009/3/04(23:26)
Bruce.です。

Zazel さんは書きました:
> http://www.faqs.org/faqs/computer-lang/awk/faq/ によると
>
> | 18. How can I split a string into characters?
> |
> | in portable POSIX awk, the only way to do this is to use substr to pull
> | out each character, one by one.  this is painful.  however, gawk, mawk,
> | and the newest version of the Bell Labs awk all allow you to set
> | FS = "" and use "" as the third argument of split.
>
> ということで、Solaris 10のnawkのマニュアルにも「結果は未定義」と
> 書いてあります。
>


空文字でsplitしたときに一文字ごとに分割されるのはPOSIX的な仕様です。
ですから、POSIX compliant なシステムであればそのように動作するのを期待し
ても良いはずです。
#まあSolarisはねえ

んで、gawkのNEWSファイルから。

Changes from 2.15.6 to 3.0.0
----------------------------
(略)

If RS is more than one character, it is treated as a regular expression
and records are delimited accordingly.  The variable RT is set to the record
terminator string. This is disabled in compatibility mode.

If FS is set to the null string (or the third arg. of split() is the null
string), splitting is done at every single character. This is disabled in
compatibility mode.

そういうことです。

-- 
木村浩一/KIMURA Koichi
 I thought what I'd do was, I'd pretend I was one of those deaf-mutes or
shoud I?
 mail kbk at kt.rim.or.jp
 web  www.kt.rim.or.jp/~kbk/zakkicho/index.html