fix UnicodeDecodeError when building user agent string