So:
- the bug shows up in 5.8.8 on my machine (linux)
- the code runs properly in 5.8.0,
- in all cases the path itself is correct (if you print it, as are lc($str) and substr( $str, 1)
- you need a fairly specific test case (you can remove the 'B' element or the 'b' and you still get the bug, but if you remove both then you get the proper output,
- if you only print the data for the problematic element... everything is fine.
This looks extremely weird. I can only guess that the usual suspect, unicode, is involved... but how?
Any help on this one would be appreciated.