diff roundup/anypy/strings.py @ 5492:6b0c542642be

blobfiles now always stores/returns bytes any conversation is done in the backend layer added a special "binary_content" property to read the data as bytes changed history generation to read property data on demand
author Christof Meerwald <cmeerw@cmeerw.org>
date Sun, 12 Aug 2018 16:05:42 +0100
parents 55f09ca366c4
children bb7865241f8a
line wrap: on
line diff
--- a/roundup/anypy/strings.py	Mon Aug 06 20:52:15 2018 +0100
+++ b/roundup/anypy/strings.py	Sun Aug 12 16:05:42 2018 +0100
@@ -27,6 +27,16 @@
     else:
         return s
 
+def bs2b(s):
+    """Convert a string object or UTF-8 encoded bytes to UTF-8 encoded bytes."""
+    if _py3:
+        if isinstance(s, bytes):
+            return s
+        else:
+            return s.encode('utf-8')
+    else:
+        return s
+
 def s2u(s, errors='strict'):
     """Convert a string object to a Unicode string."""
     if _py3:

Roundup Issue Tracker: http://roundup-tracker.org/