eachchar bug?

Look what happens when you add spaces to the eachchar example from the help. I'm assuming this is a bug.

table: eachcharexample
[ Nec  ro man cer >> eachchar mangle]

table: mangle
[{$1} >> lowercase]
[{$1} >> uppercase]

This produces output like the following.

I tried other characters. Eachchar works as expected for alphanumeric characters and most punctuation marks, but if there's a space, {$1} holds the previous non-space character instead of a space. I included two spaces after "Nec" which is why you see a C three times in a row.

My intended purpose, by the way, was to count the spaces in a given string. I'm not seeing a way to do that, but it wasn't critical. I can do without it.


  • I found a way to count spaces after all. For the case in hand, I can assume that "!" never appears in text. If I couldn't find a useful substitute, I'd be out of luck.

    table: eachcharexample
    [ Nec  ro man cer >> replace / /!/>> eachchar mangle] I see {spaces} spaces.
    table: mangle

    That produces a correct count:
    I see 4 spaces.

    This is a workaround for eachchar's problem with spaces. It's not ideal, but it'll do.

  • Yes, this looks like a bug. Whats happening under the hood is that IPP is generating a table call for each character, like [@mangle with {$1}], and running it. Problem is the space causes the parameter {$1} to be empty, making it look like [@mangle with ]. This should be fixable by just making sure any space is replaced with _. I'll put that on my todo list.

Leave a Comment