Replacing toString with encoding option