State management for character-by-character string parsing