SplitIntoChars

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.

So, split("chars",anarray,"") results in the array anarray containing 5 elements -- "c", "h", "a", "r", "s".

If you don't have any ^As in your string, you could try:

        string=$0;
        gsub(".", "&\001", string)
        n=split(string, anarray, "\001")
        for (i=1;i<=n;i++)
            print "character " i "is '" anarray[i] "'";