In short, you need to read the characters in, convert them in the proper members of card field values, and handle errors in formatting correctly.