If you are expecting one OR two chars then you need some way of knowing when the data entry is finished. Typically this is done by detecting the CR and/or LF generated when the user hits ENTER.
Another option is to always enter two chars, IE "01" not "just "1", but this is not normally convenient if a human is entering the data.