Here is a basic implementation of fold[0]. It does not support multibyte characters, though that would probably just require more switch cases.