Safely encode values like integers.