Add undefined and null cases for encoding argument