improved robustness of client/server encoding functions