Browse Source

Merge pull request #263 from djsilcock/patch-4

Update _compat.py
Peter Justin 8 years ago
parent
commit
954064877b
1 changed files with 3 additions and 3 deletions
  1. 3 3
      flaskbb/_compat.py

+ 3 - 3
flaskbb/_compat.py

@@ -27,15 +27,15 @@ else:           # pragma: no cover
     iteritems = lambda d: d.iteritems()
 
 
-def to_bytes(text):
+def to_bytes(text, encoding='utf-8'):
     """Transform string to bytes."""
     if isinstance(text, text_type):
-        text = text.encode('utf-8')
+        text = text.encode(encoding)
     return text
 
 
 def to_unicode(input_bytes, encoding='utf-8'):
     """Decodes input_bytes to text if needed."""
-    if not isinstance(input_bytes, string_types):
+    if not isinstance(input_bytes, text_type):
         input_bytes = input_bytes.decode(encoding)
     return input_bytes