Only set the character encoding if it has been set either implicitly or explicitly