Fixed missing assignments in character encoding switch; reset character encoding after character encoding test