Recoded CharacterCount so it is easier to maintain

I decided to redo CharacterCount, now named stringCharacterCount,
because the previous implementation was hasty and unnecessarily long.
The new version should make maintenence easier in the long run.