Commits

Branko Vukelic committed 670fe25

Fixed #1: Encode params UTF-8 before submitting

Comments (0)

Files changed (1)

mstranslator/endpoints/base.py

 """Base classes for endpoint processing"""
 
+from __future__ import unicode_literals
+
 from urllib import urlencode
 from xml.etree import ElementTree
+from copy import copy
 
 from mstranslator.utils import Constant
 
         )
 
     def get_quoted_params(self):
-        return urlencode(self.params)
+        # first get a copy of params and encode UTF-8
+        params = copy(self.params)
+        for p, v in params.items():
+            if isinstance(v, unicode):
+                params[p] = v.encode('UTF-8')
+
+        # ... then encode params
+        return urlencode(params)
 
     def get_request_url(self):
         return '%s?%s' % (self.get_endpoint_url(), self.get_quoted_params())