But as written, the definition permits generating the weird output. Which ignores the other arm of Postel's principle.
You could have the format definition forbid these characters; and then in the section about Postel's principle have "If you choose to accept forbidden characters, you MUST treat them as '?'".